Java Swing Blank JFrame coming up?

前端 未结 2 1499
面向向阳花
面向向阳花 2020-11-30 15:19

I\'m new to swing, and was wondering why sometimes my application comes up as blank, and sometimes it displays the components. It seems to be sporadic. There are no exceptio

2条回答
  •  生来不讨喜
    2020-11-30 16:08

    why sometimes my application comes up as blank, and sometimes it displays the components. It seems to be sporadic.

    It is not sporadic, it happens when you miss a frame.pack() call to tell the frame to pack all its components

    Do the following and the frame should display ok:

    mainFrame.add(componentHolder);
    mainFrame.pack();
    mainFrame.setVisible(true);
    

提交回复
热议问题