Reputation: 3
I use NetBeans IDE 8.2 to create my Layout. Unfortunately I cannot find a possibility to add the following code over the NetBeans GUI Builder:
JButton b = new JButton("click me");
b.addActionListener(new MyListener() );
I've found only a way, to add the Event "actionPerformed" over the Properties.
Thank you for support.
Upvotes: 0
Views: 189
Reputation: 59988
You can add it in your constructor :
public ConstructorGUI() {
super.setUndecorated(true);
initComponents();
...
JButton b = new JButton("click me");
b.addActionListener(new MyListener());
...
}
Or for the better practice you can create a separated method and which you can put this piece of code and call it in your constructor.
Upvotes: 0