JFrameのタイトルをJavaに変更する方法

JFrameのタイトルを変更するには、次の2つの方法があります:

まず、コンストラクタでウィンドウを作成するときにウィンドウにタイトルを付けることができます:

JFrame frame = new JFrame("タイトル");

次に、JFrame.setTitle:

JFrameフレーム= new JFrame();
frame.setTitle("タイトル");

Example:

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("私のタイトル");
jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jframe.setLocationRelativeTo(null);
jframe.pack();
jframe.setVisible(true);
}
}