Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

netbeans: How to put some title in the title bar

Tags:

java

netbeans

I developed a small desktop application in Net Beans. When i run my application there appears no title in the Windows Title bar. Is there anyway through which i specify some title which later on will appear in Windows title bar? Following is my Main method

public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new MyJFrame().setVisible(true);
            }
        });
    }
like image 220
Jame Avatar asked Sep 22 '11 05:09

Jame


2 Answers

Setting title in JFrame Netbeans Swing

You can see title property in properties window (Bottom right side). You can set title upon clicking that property. If you are unable to find property window, just click on Design tab and then on blank JFrame GUI.

like image 59
Varun Kumar Avatar answered Sep 20 '22 01:09

Varun Kumar


You can set the title bar at JFrame initialization time like this

JFrame frame = new JFrame("My Title");

or you can create public method for your custom class like

public void setTitle(String title){
    frame.setTitle(title); // for this you have declare the frame object as global for this class only
}

and use like this way

MyJFrame myframe = new MyJFrame();
myframe.setTitle("my new title");
myframe.setVisible(true);
like image 39
Pratik Avatar answered Sep 19 '22 01:09

Pratik