I have this piece of code, which should remove a label
, when a button
is pressed:
final JLabel label = new JLabel("Label text");
rightPanel.add(label);
final JButton remove = new JButton("Remove label");
leftPanel.add(remove);
add.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
rightPanel.remove(label);
}
});
But when I click on the button
, it doesn't remove the label text. Only when I resize the window (for example set it to full screen), the label text dissapears.