Example usage for javax.swing JOptionPane showMessageDialog

List of usage examples for javax.swing JOptionPane showMessageDialog

Introduction

In this page you can find the example usage for javax.swing JOptionPane showMessageDialog.

Prototype

public static void showMessageDialog(Component parentComponent, Object message) throws HeadlessException 

Source Link

Document

Brings up an information-message dialog titled "Message".

Usage

From source file:Main.java

public static void main(String args[]) {

    int choose = JOptionPane.showConfirmDialog(null, "Open Dialog  ??");

    if (choose == JOptionPane.YES_OPTION) {
        JOptionPane.showMessageDialog(null, "You Clicked Yes !!");
    } else if (choose == JOptionPane.NO_OPTION) {
        JOptionPane.showMessageDialog(null, "You Clicked NO");
    }/*from  w  w w .j ava  2 s.  c o m*/
}

From source file:Main.java

public static void main(final String args[]) {
    JButton button = new JButton("Test");
    button.setToolTipText("Help text for the button");

    JOptionPane.showMessageDialog(null, button);
}

From source file:Main.java

public static void main(String[] args) {
    JLabel label = new JLabel("Username :", JLabel.RIGHT);
    label.setVerticalAlignment(JLabel.TOP);

    JOptionPane.showMessageDialog(null, label);

}

From source file:Main.java

public static void main(String[] argv) {
    JTextField textfield = new JTextField(10);
    textfield.setHorizontalAlignment(JTextField.RIGHT);

    JOptionPane.showMessageDialog(null, textfield);
}

From source file:Main.java

public static void main(String[] args) {
    JLabel label = new JLabel("Username :", JLabel.RIGHT);

    label.setToolTipText("A tool tip with me!");

    JOptionPane.showMessageDialog(null, label);

}

From source file:MesageDialogWithStringArray.java

public static void main(final String[] args) {
    JFrame parent = new JFrame();

    String multiLineMsg[] = { "Hello,", "World" };
    JOptionPane.showMessageDialog(parent, multiLineMsg);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    JLabel label = new JLabel("<html><b><font size=+2>" + "<center>Hello!<br><i>Press me now!</html>");

    JOptionPane.showMessageDialog(null, label);

}

From source file:Main.java

public static void main(final String args[]) {
    JButton button = new JButton("Test");

    button.addActionListener(e -> System.out.println("Button pressed"));

    JOptionPane.showMessageDialog(null, button);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    // Modal dialog with OK button
    String message = "Line1\nLine2";
    JFrame frame = new JFrame();
    JOptionPane.showMessageDialog(frame, message);
}

From source file:Main.java

public static void main(final String args[]) {
    JButton button = new JButton("Text Button");
    button.setMnemonic(KeyEvent.VK_B);

    JOptionPane.showMessageDialog(null, button);
}