JSwing components don't appear until frame is resized [duplicate]

佐手、 提交于 2019-12-11 23:18:44

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/34645125/jswing-components-dont-appear-until-frame-is-resized

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!