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 bigNumber = 30001;
    String[] bigData = new String[bigNumber];
    for (int ii = 0; ii < bigNumber; ii++) {
        bigData[ii] = "String " + (ii + 1);
    }/*  w  w w .  j  ava2 s. c  om*/
    JList list = new JList(bigData);
    list.setVisibleRowCount(5);

    JOptionPane.showMessageDialog(null, new JScrollPane(list));
}

From source file:Main.java

public static void main(String[] args) {
    JTable t = new JTable(new TimesTableModel());
    t.setDefaultRenderer(Object.class, new TimesTableRenderer());
    JOptionPane.showMessageDialog(null, t);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    File f = new File("index.html");
    JEditorPane jep = new JEditorPane(f.toURI().toURL());

    JScrollPane sp = new JScrollPane(jep);
    sp.setPreferredSize(new Dimension(400, 200));

    JOptionPane.showMessageDialog(null, sp);
}

From source file:Main.java

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

    label.addActionListener(e -> {//from   w  ww .j av a  2 s .c om
        System.out.println("hi");
    });

    JOptionPane.showMessageDialog(null, label);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    MyTextField component = new MyTextField(10);
    MyTextField component2 = new MyTextField(10);

    JPanel p = new JPanel();
    p.add(component);//from  ww  w  .j  ava2s.  c  om
    p.add(component2);
    JOptionPane.showMessageDialog(null, p);

}

From source file:Main.java

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

    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("Button pressed");
        }/*from  ww  w .  ja v a  2 s  . c  om*/
    });

    JOptionPane.showMessageDialog(null, button);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    URL url = new URL("http://www.java2s.com/style/download.png");
    BufferedImage origImg = ImageIO.read(url);

    JOptionPane.showMessageDialog(null, new JLabel(new ImageIcon(origImg)));

    File newFile = new File("new.png");
    ImageIO.write(origImg, "png", newFile);
    BufferedImage newImg = ImageIO.read(newFile);

    JOptionPane.showMessageDialog(null, new JLabel("New", new ImageIcon(newImg), SwingConstants.LEFT));
}

From source file:Main.java

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

    button.setHorizontalTextPosition(SwingConstants.LEFT);
    button.setIcon(new ImageIcon("r.gif"));
    button.setRolloverIcon(new ImageIcon("b.gif"));
    button.setRolloverEnabled(true);/*from www .  j  a  v a2  s  . co m*/

    JOptionPane.showMessageDialog(null, button);
}

From source file:Main.java

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

    //JLabel label2 = new JLabel("Password :", JLabel.RIGHT);
    //JLabel label3 = new JLabel("Confirm Password :", JLabel.RIGHT);
    //JLabel label4 = new JLabel("Remember Me!", JLabel.LEFT);
    //JLabel label5 = new JLabel("Hello.", JLabel.CENTER);

    JOptionPane.showMessageDialog(null, label);

}

From source file:Main.java

public static void main(String[] a) {
    JTextField jTextField1 = new JTextField();

    jTextField1.setText("java2s.com");

    jTextField1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("action");
        }//from w  w w.  j  a  va 2 s  . co  m
    });
    JOptionPane.showMessageDialog(null, jTextField1);
}