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(final String args[]) {
    String s = "<html><sup>HTML</sup> <sub><em>Button</em></sub><br>"
            + "<font color=\"#FF0080\"><u>Multi-line</u></font>";
    JButton button = new JButton(s);

    JOptionPane.showMessageDialog(null, button);
}

From source file:Main.java

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

    button.addActionListener(new ClickListener());
    JOptionPane.showMessageDialog(null, button);

    button.doClick();/*from   w  w w . j av a 2s.c om*/
}

From source file:Main.java

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

    // Get gap size; default is 4
    int gapSize = button.getIconTextGap();

    // Set gap size
    button.setIconTextGap(8);/*from ww  w.  java  2  s .c om*/

    JOptionPane.showMessageDialog(null, button);
}

From source file:Main.java

public static void main(final String args[]) {
    JButton button = new JButton();
    Icon pressedIcon = new ImageIcon("pres-icon.gif");
    button.setPressedIcon(pressedIcon);/*from  w ww.j a v  a2 s.c o  m*/

    JOptionPane.showMessageDialog(null, button);
}

From source file:Main.java

public static void main(String[] args) {
    final JEditorPane editPane1 = new JEditorPane("text/html", "Try ty\tping some tabs");
    editPane1.setPreferredSize(new Dimension(400, 300));
    JOptionPane.showMessageDialog(null, new JScrollPane(editPane1));
    JOptionPane.showMessageDialog(null, new JScrollPane(new JEditorPane("text/html", editPane1.getText())));
}

From source file:Main.java

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

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setSize(200, 200);/*from w w w  .ja  va 2  s  .c  o m*/
    frame.setVisible(true);

    JOptionPane.showMessageDialog(frame, "A");
    JOptionPane.showMessageDialog(frame, "B", "message", JOptionPane.WARNING_MESSAGE);

    int result = JOptionPane.showConfirmDialog(null, "Remove now?");
    switch (result) {
    case JOptionPane.YES_OPTION:
        System.out.println("Yes");
        break;
    case JOptionPane.NO_OPTION:
        System.out.println("No");
        break;
    case JOptionPane.CANCEL_OPTION:
        System.out.println("Cancel");
        break;
    case JOptionPane.CLOSED_OPTION:
        System.out.println("Closed");
        break;
    }

    String name = JOptionPane.showInputDialog(null, "Please enter your name.");
    System.out.println(name);

    JTextField userField = new JTextField();
    JPasswordField passField = new JPasswordField();
    String message = "Please enter your user name and password.";
    result = JOptionPane.showOptionDialog(frame, new Object[] { message, userField, passField }, "Login",
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
    if (result == JOptionPane.OK_OPTION)
        System.out.println(userField.getText() + " " + new String(passField.getPassword()));

}

From source file:Main.java

public static void main(String[] args) {
    JPanel myPanel = new JPanel();
    JTextField field1 = new JTextField(10);
    JTextField field2 = new JTextField(10);
    myPanel.add(field1);// w w w.  j a va  2s .  c o m
    myPanel.add(field2);
    JOptionPane.showMessageDialog(null, myPanel);
    System.out.println(field1.getText() + field2.getText());
}

From source file:Main.java

public static void main(String[] args) {
    Icon icon = new ImageIcon("yourImage.png");
    JLabel label = new JLabel("Full Name :", icon, JLabel.LEFT);

    label.setIcon(new ImageIcon("b.png"));

    JOptionPane.showMessageDialog(null, label);

}

From source file:Main.java

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

    ImageIcon icon = new ImageIcon(new URL("http://www.java2s.com/style/download.png"));

    UIManager.put("OptionPane.informationIcon", icon);

    JOptionPane.showMessageDialog(null, "Hello!");
}