Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remember actions in Java

Status
Not open for further replies.

Jimguld

Programmer
Mar 4, 2003
26
0
0
DK
Hi I am trying to build a sort of memorizer in Java. Try to imagine that I have selected a text item from five comboboxes. Only when all comboboxes are selected it represents a state where a button becomes enabled, otherwise the button will be disables.

Then I wish to rember my selections and sent an event if just one of the selected item changes in one of the comboboxes...when this occurs the button becomes anabled again.

Any suggestions on how to build this...and how to sent such an event...

Cheers
Jim
 
As a starting point create a JComboBox listener class. Instantiate one, and "add" it to each ComboBox (CB).

As the user makes a selection on any of the CBs, the listener.actionPerformed(ActionEvent e) method will be called. An ActionEvent is passed (e), and e.getSource() returns the JComboBox that the user has made a selection on.

On the listener, have 'n' flags (ie booleans) for each CB, initially set to false, indicating the user has not made a selection on any CBs.

As each is selected, set the appropriate flag indicating that the CB has been selected, when all have been set, enable the button.

is that what you had in mind?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top