tags:

views:

227

answers:

3

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 ActionListeners.

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
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
A: 
JButton newCustomer = new JButton();

newCustomer.addActionListener(new ActionListener(){

    public void actionPerformed(ActionEvent e){
        // TODO bind the new customer menu dialog box 
    }

});
Rickster