GUIs


GUIs with Visual Editor

 

GUI_IO.java - input and output message boxes
Outer.java - buttons and actionlisteners
MakeText.java - text boxes
Bunny.java
BunnyGUI.java

 

Read D&D 12, 22


Classwork


Create a class Contribution representing a (possibly recurring) donation, for which we need to store an email address, an amount (cannot be 0 or less),  and a number of months (defaults to 1, cannot be less).

Set up a JFrame using NetBeans' editor, give it a Contribution as an instance variable.

By editing the constructor for the JFrame, use JOptionPane's showInputDialog method to make an input box pop up at the beginning of the program to get the user's email, and use this in the Contribution.

For the GUI, in addition to the widgets required below, think about layout and adding extra JLabels to make it clear to the user the current state of the Contribution and how they should use the GUI.

Add one or more JLabels to the GUI which display the current information for the Contribution.  Whenever the Contribution is updated, make sure these get updated too.

Add to the GUI an editable text field for the user to enter an amount.  When the user hits enter from this text field, update the contribution.  

Add to the GUI an editable text field for the user to enter an number of months. When the user hits enter from this text field, update the contribution. 

For both these text fields, if the input given is not valid (including not a number at all), pop up a message box scolding the user.   

Add a button to the GUI that says "Submit".  Use setEnabled(false) to make sure it starts off greyed out.  If the donation amount is over $0.99, enable it (but if the amount is reduced below $1.00, disable it again).  When clicked, pop up a message thanking the user.

[EC] Add an extra label that shows the total amount across all months (this is not what is stored in the Contribution class) and update it when months or amount is updated.