Java GUI shows blank until resize

前端 未结 2 1804
伪装坚强ぢ
伪装坚强ぢ 2021-01-16 05:24

I have written a java gui code for many options available on it. the gui is also set visible true but it doesn\'t show until I pick its border and drag them to resize the gu

相关标签:
2条回答
  • 2021-01-16 05:46
    frame.setVisible(true);
    

    This Statement should be invoked in the last of adding other components to the Frame.

    0 讨论(0)
  • 2021-01-16 05:48
    frame.setVisible(true) ;
    

    The above statement should be invoked AFTER all the components have been added to the frame. So it should be the last statement in your method.

    Also, you should be invoking:

    frame.pack();
    

    instead of setSize(), before making the frame visible so all the components are displayed at their preferred size.

    0 讨论(0)
提交回复
热议问题