i am trying to bind a new customer menu dialog box to a newCustomer button in my application , any ideas? thanks
+2
A:
Well to bind actions in java you add ActionListener
s.
When constructing your button you need to add an ActionListener to it. That way, when the click event happens, the button knows what to do.
newCustomerButon.add(new ActionListener(){
public void actionPerformed(ActionEvent e){
// This is where you put the code for popping up the form.
yourForm.setVisible(true); // Or something similar.
}
});
jjnguy
2009-06-05 18:18:22
A:
As far as I know, there are several add() methods which are inherited from Component, but none of which will add an ActionListener to a JButton. Do you mean addActionListener() instead?
itrekkie
2009-06-05 18:41:22
A:
JButton newCustomer = new JButton();
newCustomer.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
// TODO bind the new customer menu dialog box
}
});
Rickster
2009-06-10 21:19:41