JSwing components don't appear until frame is

2019-09-05 18:21发布

This question already has an answer here:

bit of an issue. I'm trying to make a JSwing frame with a label, textfield, and two buttons. When the routine first runs, the buttons and the textframe are invisible. When I resize the frame, the buttons and textframe appear, and remain there when I return the frame to its original size. Any ideas why this is happening?

2条回答
Explosion°爆炸
2楼-- · 2019-09-05 18:31

You should call setVisible(true) on your frame after you added the components to get them rendered in your frame. See this answer for more information.

查看更多
聊天终结者
3楼-- · 2019-09-05 18:41

After adding the elements, you may want to call revalidate(). Post your code for more help.

查看更多
登录 后发表回答