• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

wrapping program in gui

 
Ranch Hand
Posts: 33
Android Mac OS X
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I have simple digital root calculator program that i would like to add a GUI to; rather than create a whole new program, someone suggested that i simply wrap the old one in a GUI. any suggestions on how to do this?
Here is the original program:
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What kind of GUI? Swing? Web?

Regardless, it's not going to be that simple. Depending upon which type of GUI you choose, the method of accepting input will change drastically from reading in from the console.
 
Marshal
Posts: 79262
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have a calculator with a proper public interface, it is not that difficult really. It might take a long time to learn all the Swing components, however.
Do you have methods like add() subtract() divide() multiply()?
Do you have methods like takeParameter(), takeOperator()?
When you have such methods and you can do this sort of thing, you have a chance of wrapping it in a GUI:-ORYou don’t need to do both; either will work (but differently).
In your case, it would appear that you might only have one operator (Operators.SQUARE_ROOT) or one method (squareRoot()).

Actually what you are doing is working out the transverse sum of the digits modulo 9. I mistook it for square root.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kirstie Fran wrote:any suggestions on how to do this?


Yes, but it's going to be difficult to achieve with your program as it is: You need to keep your calculator and your input/display (be it GUI, console or browser-based) completely separate.

And that means, as Campbell said, coming up with a public API for your calculator.

Right now, they're all mixed up together, so your first cut should be to remove all those Scanner.get... and System.out.println() statements from your calculator and put them in another class (CalculatorDialog?). Once you have that, you'll probably find it a lot simpler to re-write to use GUI components.

Winston
 
Kirstie Fran
Ranch Hand
Posts: 33
Android Mac OS X
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:What kind of GUI? Swing? Web?

Regardless, it's not going to be that simple. Depending upon which type of GUI you choose, the method of accepting input will change drastically from reading in from the console.


it would be a swing gui. I'm using a jframe.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic