java 代码
- JOptionPane.showInputDialog(null, "Please choose a name", "Example 1",
- JOptionPane.QUESTION_MESSAGE, null, new Object[] {
- "Amanda", "Colin", "Don", "Fred", "Gordon", "Janet", "Jay", "Joe",
- "Judie", "Kerstin", "Lotus", "Maciek", "Mark", "Mike", "Mulhern",
- "Oliver", "Peter", "Quaxo", "Rita", "Sandro", "Tim", "Will"}, "Joe");
- JOptionPane.showInputDialog(null, "Please enter your name", "Example 2",
- JOptionPane.QUESTION_MESSAGE, null, null, "Shannon");
- JOptionPane.showMessageDialog(null, "Have a nice day.", "Example 3",
- JOptionPane.INFORMATION_MESSAGE, new ImageIcon("images/smile.gif"));
- JOptionPane.showConfirmDialog(null, "Are you sure?", "Example 4",
- JOptionPane.YES_NO_CANCEL_OPTION);
- JOptionPane.showInternalOptionDialog(desk, "Please select a color",
- "Example 5", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE,
- null, new Object[] {"Red", "Green", "Blue"}, "Blue");
- JFrame f = new JFrame( );
- Container c = f.getContentPane( );
- c.setLayout(new BorderLayout( ));
- JOptionPane op = new JOptionPane("Stop!", JOptionPane.WARNING_MESSAGE);
- JPanel p = new JPanel(new FlowLayout( ));
- p.add(op);
- c.add(p);
- c.add(new JLabel("Example 6", JLabel.CENTER), BorderLayout.NORTH);
- f.setVisible(true);