I have GUI created using netbeans GUI builder. I want to add there an object (let's try with button) after pressing a JButton
The very simple code which I wrote in ActionListener and works:
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
panel2.add(new JButton("X"));
panel2.validate();
}
});
Howewer in Gui created by netbeans this doesnt work:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
jPanel1.add(new JButton("X"));
jPanel1.validate();
System.out.print("aa");
}
But it prints "aa" so action listener works.
It looks like a similar problem to one showed here: http://bytes.com/topic/java/answers/857720-adding-icon-jpanel
but I can't see even that rectangle about which JosAH wrote.
I'll appreciate any suggestion.