Pages

Set JFrame title

Source code below will show how to set JFrame title

******************************************************************
COMPLETE SOURCE CODE FOR : SetJFrameTitle.java
******************************************************************


import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class SetJFrameTitle
{
public static void main(String[]args)
{
//Create input dialog that will use to receive JFrame title
String jframeTitle=JOptionPane.showInputDialog(null,"Put JFrame title here");

//Create a JFrame
JFrame frame=new JFrame();

//Set title for JFrame
//Method setTitle() is use to set JFrame title
frame.setTitle(jframeTitle);

//Set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,400);

//Make JFrame visible
frame.setVisible(true);
}
}


******************************************************************
JUST COMPILE AND EXECUTE IT
******************************************************************
Related Posts Plugin for WordPress, Blogger...