GUI Elements Not Showing Immediately

Tags: ,



I made a redesign to my gui in java and it is facing an issue, the icons don’t show until i grab the gui and shake it, sometimes they show half then i have to grab it by the mouse and check it again for the icons to show, what could be causing that and how to fix it ?

Answer

  1. Components should be added to the frame BEFORE the frame is made visible
  2. If you add components to a panel on a visible frame, then you need to invoke revalidate() on the panel after adding all the components.


Source: stackoverflow