调整框架大小后,JSwing组件才会出现 [英] JSwing components don't appear until frame is resized

查看:74
本文介绍了调整框架大小后,JSwing组件才会出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

位。我正在尝试制作一个带有标签,文本字段和两个按钮的JSwing框架。当例程第一次运行时,按钮和文本框是不可见的。当我调整框架的大小时,按钮和文本框架会出现,并且当我将框架恢复为其原始大小时,按钮和文本框架会保留在那里。任何想法为什么会发生这种情况?

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?

推荐答案

您应该调用 setVisible(true)。有关更多信息,请参见此 answer

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.

这篇关于调整框架大小后,JSwing组件才会出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆