JOptionPane
JOptionPane.showMessageDialog
import javax.swing.JOptionPane;

public class Dialog
{
	public static void main(String args[])
	{
		JOptionPane.showMessageDialog(null, "Welcome to Java");
	}
}
			
JOptionPane.showInputDialog
import javax.swing.JOptionPane;

public class Dialog2
{
	public static void main(String args[])
	{
		String name = JOptionPane.showInputDialog("What is your name?");
		System.out.printf("You name: %s\n", name);
	}
}
			
JOptionPane.showInputDialog + JOptionPane.showMessageDialog
import javax.swing.JOptionPane;

public class Dialog3
{
	public static void main(String args[])
	{
		String name = JOptionPane.showInputDialog("What is your name?");
		String message = String.format("Welcom, %s, to Java Programming!", name);

		JOptionPane.showMessageDialog(null, message, "Java Message", JOptionPane.DEFAULT_OPTION);
	}
}
			
JOptionPane.showInputDialog + JOptionPane.showMessageDialog + ImageIcon
import javax.swing.JOptionPane;
import javax.swing.ImageIcon;

public class Dialog4
{
	public static void main(String args[])
	{
		String name = JOptionPane.showInputDialog("What is your name?");
		String message = String.format("Welcom, %s, to Java Programming!", name);

		ImageIcon icon = new ImageIcon("./java-icon.png", "Java Logo");
		JOptionPane.showMessageDialog(null, message, "Java Message", JOptionPane.DEFAULT_OPTION, icon);
	}
}
			
JOptionPane.showConfirmDialog
import javax.swing.JOptionPane;
import javax.swing.ImageIcon;

public class Dialog5
{
	public static void main(String args[])
	{
		//0, yes
		//1, no
		//2, cancel
		int choice = JOptionPane.showConfirmDialog(null, "Are you 21 years or older?");

		if (choice == 0)
			JOptionPane.showMessageDialog(null, "Welcome, you can drink");
		else if (choice == 1)
			JOptionPane.showMessageDialog(null, "No, you cannot drink");
		else
			JOptionPane.showMessageDialog(null, "You don't want to tell us your age");
	}
}
			
JOptionPane.showOptionDialog
import javax.swing.JOptionPane;

public class Dialog6
{
	public static void main(String args[])
	{
		Object[] options = {"Happy", "Cry", "Smile", "CANCEL"};

		int choice = JOptionPane.showOptionDialog(null, "Click OK to continue", "Warning",
				JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
				null, options, options[0]);

		String message = String.format("Your choice is: %s\n", options[choice]);

		JOptionPane.showMessageDialog(null, message);
	}
}
			
Reference