netbeans:如何在标题栏中放置一些标题
问题描述:
我在Net Beans中开发了一个小型桌面应用程序。当我运行我的应用程序时,在Windows标题栏中看不到标题。无论如何,通过我指定一些标题,稍后将出现在Windows标题栏?以下是我的主要方法netbeans:如何在标题栏中放置一些标题
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MyJFrame().setVisible(true);
}
});
}
答
您可以设置JFrame的初始化时的标题栏这样
JFrame frame = new JFrame("My Title");
,或者你可以创建public方法你定制类如
public void setTitle(String title){
frame.setTitle(title); // for this you have declare the frame object as global for this class only
}
,并使用像这样
MyJFrame myframe = new MyJFrame();
myframe.setTitle("my new title");
myframe.setVisible(true);
答
myTopLevelContainer = new myTopLevelContainer("myTitlaLabel");
或
myTopLevelContainer.setTitle("myTitlaLabel");
答
为了让您的应用程序标题,右键单击JFrame中,并打开其属性对话框。点击属性标签。
在Properties选项卡下,找到并修改title
字段。 NetBeans将完成剩下的工作。
答
好了,这个工作对我来说...
public yourGUIname() {
initComponents();
this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("your image here")));
this.setTitle("your title here"); // that is the code you looking for
}
所以我所做的就是把上面的代码中产生的公共方法。
什么是MyJPane()? – Pratik
@Pratik:用于创建UI,我首先添加JFrame,然后拖放所有控件 public class MyJPane extends javax.swing.JFrame {。 。 。 } – Jame