How to change the title of JFrame to Java
There are two ways to change the title of JFrame:
First, you can give a title to your window when creating it in the constructor:
Second, once you have created the instance of the JFrame object, you can call the method JFrame.setTitle:
Example:
To help you I give you this code from the modification of the title of JFrame:
First, you can give a title to your window when creating it in the constructor:
JFrame frame = new JFrame("Title"); |
Second, once you have created the instance of the JFrame object, you can call the method JFrame.setTitle:
JFrame frame = new JFrame(); frame.setTitle("title"); |
Example:
To help you I give you this code from the modification of the title of JFrame:
import java.awt.Dimension;
import javax.swing.JFrame;
public class Test extends JFrame{
public static void main(String[] args) {
JFrame jframe = new JFrame();
jframe.setTitle("my title");
jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jframe.setLocationRelativeTo(null);
jframe.pack();
jframe.setVisible(true);
}
}