List of usage examples for javax.swing JOptionPane showMessageDialog
public static void showMessageDialog(Component parentComponent, Object message) throws HeadlessException
From source file:Main.java
License:asdf
public static void main(String[] args) { JButton bn = new JButton("asdf"); bn.addPropertyChangeListener(new AbstractButtonPropertyChangeListener()); bn.setText("java2s.com"); JOptionPane.showMessageDialog(null, bn); }
From source file:Main.java
public static void main(String[] args) throws Exception { final String html = "<html><body>" + "<img src='" + "http://www.java2s.com/style/download.png" + "' width=160 height=120> " + "<img src='" + "http://www.java2s.com/style/download.png" + "' width=160 height=120>" + "<p>Message!"; JLabel hover = new JLabel("Point at me!"); hover.setToolTipText(html);/*from w w w .j a v a 2 s .c o m*/ JOptionPane.showMessageDialog(null, hover); }
From source file:Main.java
public static void main(String[] args) { final JFrame frame = new JFrame(); JOptionPane pane = new JOptionPane("Some message", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION) { @Override// w ww. j a v a2 s. c om public void setValue(Object newValue) { super.setValue(newValue); JOptionPane.showMessageDialog(frame.getContentPane(), "You have hit " + newValue); } }; frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(new JLabel("Some panel in the middle"), BorderLayout.CENTER); frame.add(pane, BorderLayout.SOUTH); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { Integer[] numbers = { 1, 2, 3 }; String[] names = { "A", "B", "C" }; JComboBox numberCombo = new JComboBox(numbers); JComboBox nameCombo = new JComboBox(names); JPanel p = new JPanel(new GridLayout(0, 1, 3, 3)); p.add(numberCombo);//from www .j a v a 2 s . c o m p.add(nameCombo); JOptionPane.showMessageDialog(null, p); Integer chosenNumber = (Integer) numberCombo.getSelectedItem(); System.out.println("Chosen Number: " + chosenNumber); String chosenName = (String) nameCombo.getSelectedItem(); System.out.println("Chosen Name: " + chosenName); }
From source file:Main.java
public static void main(String[] args) throws Exception { URL url = new URL("http://www.java2s.com/style/download.png"); final Image img = ImageIO.read(url); Runnable r = new Runnable() { @Override/*w w w . j a va 2 s . c o m*/ public void run() { JOptionPane.showMessageDialog(null, new JLabel(new ImageIcon(img))); } }; SwingUtilities.invokeLater(r); }
From source file:Main.java
public static void main(String[] args) { JLabel label = new JLabel("java2s.com", JLabel.LEFT); label.setHorizontalAlignment(JLabel.CENTER); label.setVerticalAlignment(JLabel.CENTER); //label.setHorizontalAlignment(JLabel.LEFT); //label.setVerticalAlignment(JLabel.TOP); //label.setHorizontalAlignment(JLabel.RIGHT); //label.setVerticalAlignment(JLabel.BOTTOM); JOptionPane.showMessageDialog(null, label); }
From source file:Main.java
public static void main(String[] args) { JPanel panel = new JPanel(new GridLayout(0, 5)); panel.add(new BasicArrowButton(BasicArrowButton.EAST)); panel.add(new BasicArrowButton(BasicArrowButton.NORTH)); panel.add(new BasicArrowButton(BasicArrowButton.SOUTH)); panel.add(new BasicArrowButton(BasicArrowButton.WEST)); JOptionPane.showMessageDialog(null, panel); }
From source file:Main.java
public static void main(String[] args) { Integer[][] data = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } }; String[] cols = { "A", "B", "C" }; JTable table = new JTable(data, cols); JTableHeader header = table.getTableHeader(); header.setBackground(Color.black); header.setForeground(Color.yellow); JOptionPane.showMessageDialog(null, new JScrollPane(table)); }
From source file:ConfigOptionPaneLanguage.java
public static void main(final String[] args) { // //from ww w . j a v a2 s . c o m UIManager.put("OptionPane.cancelButtonText", "Annuler"); UIManager.put("OptionPane.noButtonText", "Non"); UIManager.put("OptionPane.okButtonText", "D'accord"); UIManager.put("OptionPane.yesButtonText", "Oui"); JFrame parent = new JFrame(); String multiLineMsg[] = { "Hello,", "World" }; JOptionPane.showMessageDialog(parent, multiLineMsg); }
From source file:Main.java
public static void main(final String args[]) { ArrowButton button = new ArrowButton(SwingConstants.EAST, 1, 30); JOptionPane.showMessageDialog(null, button); button.doClick();//ww w.ja va 2s . c o m }