我在Net Beans开发了一个小型桌面应用程序.当我运行我的应用程序时,Windows标题栏中没有标题.无论如何我通过它指定一些标题,稍后将出现在Windows标题栏中?以下是我的主要方法
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MyJFrame().setVisible(true);
}
});
}
Run Code Online (Sandbox Code Playgroud)
您可以在 JFrame 初始化时设置标题栏,如下所示
JFrame frame = new JFrame("My Title");
Run Code Online (Sandbox Code Playgroud)
或者您可以为自定义类创建公共方法,例如
public void setTitle(String title){
frame.setTitle(title); // for this you have declare the frame object as global for this class only
}
Run Code Online (Sandbox Code Playgroud)
并像这样使用
MyJFrame myframe = new MyJFrame();
myframe.setTitle("my new title");
myframe.setVisible(true);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
24574 次 |
最近记录: |