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) {
    String[] items = { "1|9|2", "1|9|1", "1|4|7" };
    JList list = new JList(items);
    JPanel panel = new JPanel();
    panel.add(new JScrollPane(list));
    JOptionPane.showMessageDialog(null, panel);
}

From source file:Main.java

public static void main(String[] args) {

    JLabel label = new JLabel("Full Name :", JLabel.LEFT);

    label.setOpaque(true);/*from w ww .j  ava 2  s.  c o m*/
    label.setForeground(new Color(150, 150, 25));
    label.setBackground(new Color(50, 50, 25));

    JOptionPane.showMessageDialog(null, label);

}

From source file:Main.java

public static void main(String[] args) {
    String inputValue = JOptionPane.showInputDialog("Please input a value");

    if (inputValue == null) {
        System.out.println("CANCEL");
    } else if (inputValue.equals("")) {
        System.out.println("OK");
    } else {/*from  w ww.  j a  v a 2s  .c  o  m*/
        JOptionPane.showMessageDialog(null, inputValue);
    }
}

From source file:Main.java

public static void main(String[] args) {
    String html = "<html><body>" + "<h1>Header</h1>" + "<img src='http://www.java2s.com/style/download.png' "
            + "width='160' height='120'>";
    JLabel label = new JLabel("Point at me!");
    label.setToolTipText(html);/*from  w w  w  .jav a2s .c om*/
    JOptionPane.showMessageDialog(null, label);
}

From source file:Main.java

public static void main(String[] args) {

    JLabel label = new JLabel("java2s.com", JLabel.LEFT);
    Border border = BorderFactory.createLineBorder(Color.BLACK);
    label.setBorder(border);//from   w w  w  .java  2  s .  co  m

    JOptionPane.showMessageDialog(null, label);

}

From source file:Main.java

public static void main(String[] args) {
    JLabel label = new JLabel(
            "\u0414\u043E\u0431\u0440" + "\u043E\u0020\u043F\u043E\u0436\u0430\u043B\u043E\u0432"
                    + "\u0430\u0422\u044A\u0020\u0432\u0020Unicode\u0021");
    label.setToolTipText("This is Russian");

    JOptionPane.showMessageDialog(null, label);

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    JLabel label = new JLabel("java2s.com");

    JPanel panel = new JPanel();
    panel.add(label);/*  ww w  .  j a v  a 2 s. co  m*/
    panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    JOptionPane.showMessageDialog(null, panel);

}

From source file:Main.java

public static void main(String[] args) {
    JLabel image = new JLabel("java2s.com");
    image.setPreferredSize(new Dimension(2000, 2000));
    JScrollPane js = new JScrollPane(image);

    js.setPreferredSize(new Dimension(200, 200));

    JOptionPane.showMessageDialog(null, js);

}

From source file:Main.java

public static void main(String[] args) {
    String[] items = { "A", "B", "C", "D" };
    JComboBox<String> combo = new JComboBox<String>(items);
    combo.setEditable(true);//ww  w  .j a va 2s.  co m

    removeButton(combo);

    JOptionPane.showMessageDialog(null, combo);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    JHyperlinkLabel label = new JHyperlinkLabel("java2s.com");

    JOptionPane.showMessageDialog(null, label);

}