|
This example illustrates how to create message box and input box in swing. In this example you can see that, when user run this program on console then a input box will be appear for entering string value in the input text field. When user enter correctly the text value then the message box with entered text will be display.
Source Code of dialog.java
import java.io.*;
import javax.swing.JOptionPane;
public class dialog{
public static void main(String args[])
throws IOException{
try{
String input = JOptionPane.showInputDialog
("Welcome! Enter the Message:");
JOptionPane.showMessageDialog
(null,"your Message:"+input);
} catch (Exception e){
JOptionPane.showMessageDialog(
null,e.getMessage());
}
}
} |
|
|