Message box appear in JFrame

Complete source code below will show you, how to make message box appear in a container.

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


import javax.swing.JOptionPane;

import javax.swing.JFrame;

public class MessageBoxAppearInJFrame
{
public static void main(String[]args)
{
//Create a window using JFrame with title ( Message box appear in JFrame )
JFrame frame=new JFrame("Message box appear in JFrame");

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

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

//Make JFrame locate at center on screen
frame.setLocationRelativeTo(null);

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


//Pop up a message box with text ( I am a message dialog ) in created JFrame
JOptionPane.showMessageDialog(frame,"I am a message dialog");
}
}


**********************************************************************
JUST COMPILE AND EXECUTE IT
**********************************************************************

Create message box in java

Complete source code below will show you, how to create message box in java. We will use JOptionPane class to create message box. If you want your message box appear in a container, you can change null in source code below to target container.You can see example by click here.

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


import javax.swing.JOptionPane;

public class JavaMessageDialog
{
public static void main(String[]args)
{
//Pop up a message box with text ( I am a message dialog )
JOptionPane.showMessageDialog(null,"I am a message dialog");
}
}


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

I Also Can Create T-Shirt Logo For You