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) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JButton button = new JButton("Button");
    frame.add(button);/*w  w  w.j ava 2  s. c  om*/

    frame.setAlwaysOnTop(true);
    frame.setSize(500, 500);
    frame.setLocation(500, 500);

    button.addActionListener(e -> {
        JOptionPane optionPane = new JOptionPane("Option Pane");
        optionPane.showMessageDialog(frame, "Message!");
    });

    frame.setVisible(true);
}

From source file:Main.java

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

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

}

From source file:MainClass.java

public static void main(String args[]) {
    JOptionPane.showMessageDialog(null, "HI");
}

From source file:MessagePopUps.java

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

    JOptionPane.showMessageDialog(parent, "Printing complete");
    //    JOptionPane.showInternalMessageDialog(parent, "Printing complete");

}

From source file:Main.java

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

    JOptionPane.showMessageDialog(null, label);

}

From source file:Main.java

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

    JOptionPane.showMessageDialog(null, button);
}

From source file:Main.java

public static void main(String[] args) {
    JLabel label = new JLabel("java2s.com");
    label.setEnabled(false);/*from   w ww . j  a va 2  s.  c  o m*/

    JOptionPane.showMessageDialog(null, label);

}

From source file:Main.java

public static void main(String[] args) {

    JLabel label = new JLabel("<html>Line<br>line<br>line</html>", JLabel.LEFT);

    JOptionPane.showMessageDialog(null, label);

}

From source file:Main.java

public static void main(String[] args) {
    JTree tree = new JTree();
    tree.setVisibleRowCount(10);//from   www .j  a v a2 s.  c om
    JOptionPane.showMessageDialog(null, new JScrollPane(tree));
}

From source file:Main.java

public static void main(String[] args) {

    JLabel label = new JLabel("java2s.com", JLabel.LEFT);
    label.setText("Centered");

    JOptionPane.showMessageDialog(null, label);

}