Java Alert Box

In this example we will describe java alert box. First of all we have created class than main method after that we have created alert box method. In this method display information message to the user. We use JOptionPane class to display the message alert box. JOptionPane class is available in the javax.swing.*; package.

Java Alert Box

In this example we will describe java alert box. First of all we have created class than main method after that we have created alert box method. In this method display information message to the user. We use JOptionPane class to display the message alert box. JOptionPane class is available in the javax.swing.*; package.

Java Alert Box

Java Alert Box

In this example we will describe java alert box. First of all we have created class than main method after that we have created alert box method. In this method display information message to the user. We use JOptionPane class to display the message alert box.  JOptionPane class is available in the javax.swing.*; package.

JOptionPane is a swing application we can use JOptionPane to show message and we can use any java application. JOptionPane has three method but in this example we have used one method.

showMessageDialog():- The showMessageDialog() method which is used to display a simple message.

import javax.swing.JOptionPane;


public class AlertBoxExample {
	
	    public static void main(String[] args) {
		
		String string="Welcome to roseindia.net?";
		
		JOptionPane.showMessageDialog(null,string);

	}
}

Output:

Download Source Code