0

im Learning to make Java apps using JFrame , JPanel ,etc So when compiling it , it always return blank Panelenter image description here


But after either resizing by pulling the sides or even full screening the apps the Panel appear like this

enter image description here


How do i adjust so the Panel is shown when the apps start without the need to manually resize the screen?

This is my Display Code

        setVisible(true);
        setSize(600,400);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLocationRelativeTo(null);
        loadWeapon();
        loadMaterial();

Thanks in advance! Cheers.

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
Karen
  • 122
  • 11
  • 1
    And like ALL the other questions that have been asked - call `setVisible` AFTER you have established the UI - otherwise call `revalidate` and `repaint` on the container which has changed – MadProgrammer Mar 23 '18 at 08:07
  • Just to be sure so i add all the component like button etc to the panel first then set the visibility right? Edit: Oh yeah it works thanks @MadProgrammer – Karen Mar 23 '18 at 08:09
  • That's the easiest approach - Swing layouts are lazy, you need to tell them when you want them updated - calling `setVisible` last in this case will cause a layout pass to be triggered automatically – MadProgrammer Mar 23 '18 at 08:10

0 Answers0