PDA

View Full Version : GUI for an ATM application



Cartmann
11-23-2011, 01:16 PM
Hello fellow programmers.

I'm currently constructing an ATM(a cash dispenser) for my semester assignment.
At the moment it's using the debug (system.out.print) but i would really like some GUI to make it more neat, however, I've no experience with other things than the debug.
So my question is: how to integrate GUI into a sysout based program.

In advance, thanks :)

Aftermath
11-23-2011, 02:00 PM
If you want a GUI, you can't have it based on printing to standard output (well, you can, but that won't be visible on the GUI; it might be useful for debugging).

I assume you are doing this in Java - check out example depot section on Swing, one of the Java GUI libraries: http://www.exampledepot.com/egs/javax.swing/pkg.html

You should start looking at the JFrame - it's a GUI Window. Then, you can add JButtons to it to preform actions (e.g. select withdrawal amount, type in PIN, ...), you can use JTextField to store text (e.g. pin that user is typing in, or cash amount for withdrawal if user is not using one of the standard options you provided the buttons for). You'll need to set a Layout on your JFrame's content pane; for this, I would suggest using GridLayout.

(I basically just gave you the keywords, you can look on the page I linked for those words to get actual code).

One last thing - to make buttons do stuff, you have to add an ActionListener to them. What happens is that when the user clicks on your button, the code in the ActionListener's method to handle the event is called.

cause
11-24-2011, 07:10 PM
We're just going over that in class right now, here's the handout we get:
https://www.matygo.com/offerings/59/resource/281/files/2219/lecture11-gui-handout.pdf