Pages

Get JFrame title

Source code below will show how to get JFrame title.

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


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

public class GetJFrameTitle
{
public static void main(String[]args)
{
//Create a JFrame with title ( My first window )
JFrame frame=new JFrame("My first window");

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

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

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

//Create a message box that show JFrame title
//Method getTitle() will get JFrame title
JOptionPane.showMessageDialog(frame,"MY NAME IS : "+frame.getTitle());
}
}


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