[ACCEPTED]-java swing dynamically adding components-dynamic

Accepted answer
Score: 22

You need to call revalidate after adding (or removing) components:

rightPanel.add(label);
rightPanel.revalidate();

should 1 do the trick.

Score: 11

call

rightPanel.revalidate();
rightPanel.repaint();

after adding

0

Score: 4

just add this line after you add the label

rightPanel.updateUI();

when 2 you add any component at runtime you need 1 to update the ui using this method

More Related questions