Java Swing GUI

How to Set the Title of a JFrame in Java

In this tutorial, we are going to see how to set the title of a JFrame in java. To set the title of a JFrame, you can use JFrame.setTitle(String title) method. See the example below.
 

Java Program to Set the Title of a JFrame:
import javax.swing.JFrame;

public class Main 
{  
  public static void main(String[] args)
  {
	   JFrame frame = new JFrame();
	   frame.setSize(300, 300);    
	   frame.setTitle("Welecome to StackHowTo!");
	   frame.setVisible(true);
  }
}

Output:

 
[st_adsense] mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *