show dialog java code example

Example 1: dialog box in java swing

import javax.swing.JOptionPane;

public class Main {
  public static void main(String[] argv) throws Exception {

    JOptionPane.showMessageDialog(null, "I am happy.");

  }
}

Example 2: show input dialog java

import javax.swing.JOptionPane;

public class SimpleInputDialog1 {

    public static void main(String[] args){

        String m = JOptionPane.showInputDialog("Anyone there?");
        System.out.println(m);

    }

}

Example 3: java swing dialog box

JOptionPane.showMessageDialog(null, "java is fun");

Tags:

Java Example