java JFrame 可见性

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15879120/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 21:09:59  来源:igfitidea点击:

JFrame visibility

javaswingnetbeansjframevisible

提问by Abdelrahman Wahdan

I tried to make a JFrame with netbeans IDE and all the code has no error, when I try to run the application the Frame is not visible. what is the problem?

我尝试使用 netbeans IDE 制作 JFrame 并且所有代码都没有错误,当我尝试运行该应用程序时,Frame 不可见。问题是什么?

回答by Abdelrahman Wahdan

I'm sure you forgot to write this code:

我确定你忘记写这段代码了:

setVisible(true);

回答by Abdelrahman Wahdan

Before you do

在你做之前

setVisible(true);

Make sure that you made a constructor like:

确保您创建了一个构造函数,例如:

public YourFrame(){
setVisible(true);
}

I hope this helps you.

我希望这可以帮助你。