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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Which combobox selected

Status
Not open for further replies.

eh171

Programmer
Joined
Feb 21, 2003
Messages
9
Location
GB
I have 3 comboboxes in a frame. When the user clicks on 1 of the boxes I want to return the box selected???
 
And why do you want to return the box selected pray tell. -------------------------------------------
There are no onions, only magic
-------------------------------------------
 
If I understand you correct then I guess you want to know which combobox you actually selected from.
Implement a actionlistener...



public class mybox implement java.awt.eveny.ActionLister extends JFrame
{

JComboBox box = new JComboBox();
box.addActionListener(this);

//This method also handles both components
public void actionPerformed(ActionEvent e)
{
//This tells you which combobox you are selection..
if (e.getSource() ==box)
{
//add code here
}
}
}

Regards
Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top