List of usage examples for javax.swing JOptionPane PLAIN_MESSAGE
int PLAIN_MESSAGE
To view the source code for javax.swing JOptionPane PLAIN_MESSAGE.
Click Source Link
From source file:Main.java
public static void main(String... args) { JOptionPane optionPane = new JOptionPane("Its me", JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, null, "Please ENTER your NAME here"); optionPane.setWantsInput(true);//w w w. ja va 2 s . com JDialog dialog = optionPane.createDialog(null, "TEST"); dialog.setLocation(10, 20); dialog.setVisible(true); System.out.println(optionPane.getInputValue()); }
From source file:Main.java
public static void main(String[] args) { int option = JOptionPane.showOptionDialog(null, "Title", "Message", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, State.values(), State.values()[0]); if (option == JOptionPane.CLOSED_OPTION) { System.out.println("user closed the JOptionPane without selecting"); } else {/*from w w w.ja va2 s .co m*/ State state = State.values()[option]; doAction(state); System.out.println("code to do something based selected state"); } }
From source file:Main.java
public static void main(String[] args) { String[] possibilities = { "Adult Ticket", "Childs Ticket", "Over Fifty Ticket" }; String s = (String) JOptionPane.showInputDialog(null, "What ticket would you like to buy?", "Ticket Dialog", JOptionPane.PLAIN_MESSAGE, null, possibilities, possibilities[0]); switch (s) {/*from w ww .j ava 2 s . c om*/ case "Adult Ticket": System.out.println("Buy Adult"); break; case "Childs Ticket": System.out.println("Child Adult"); break; case "Over Fifty Ticket": System.out.println("Over Fifty Adult"); break; } }
From source file:Main.java
public static void main(String[] args) { Icon errorIcon = UIManager.getIcon("OptionPane.errorIcon"); Object[] possibilities = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; Integer i = (Integer) JOptionPane.showOptionDialog(null, null, "ShowInputDialog", JOptionPane.PLAIN_MESSAGE, 1, errorIcon, possibilities, 0); // or//from w w w.j a v a 2s . co m Integer ii = (Integer) JOptionPane.showInputDialog(null, "Select number:\n\from JComboBox", "ShowInputDialog", JOptionPane.PLAIN_MESSAGE, errorIcon, possibilities, "Numbers"); }
From source file:Main.java
public static void main(String[] args) { Icon errorIcon = UIManager.getIcon("OptionPane.errorIcon"); Object[] possibilities = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }; Integer i = (Integer) JOptionPane.showOptionDialog(null, null, "ShowInputDialog", JOptionPane.PLAIN_MESSAGE, 1, errorIcon, possibilities, 0); Integer ii = (Integer) JOptionPane.showInputDialog(null, "Select number:\n\from JComboBox", "ShowInputDialog", JOptionPane.PLAIN_MESSAGE, errorIcon, possibilities, "Numbers"); }
From source file:Main.java
public static void main(String[] args) { String[] weekdays = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" }; final JComboBox<String> combo = new JComboBox<>(weekdays); String[] options = { "OK", "Cancel", "Help" }; String title = "Title"; int selection = JOptionPane.showOptionDialog(null, combo, title, JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]); if (selection > 0) { System.out.println("selection is: " + options[selection]); }/* w ww . jav a2 s .com*/ Object weekday = combo.getSelectedItem(); if (weekday != null) { System.out.println("weekday: " + weekday); } }
From source file:Main.java
public static void main(String[] args) { Object[] options1 = { "Try This Number", "Choose A Random Number", "Quit" }; JPanel panel = new JPanel(); panel.add(new JLabel("Enter number between 0 and 1000")); JTextField textField = new JTextField(10); panel.add(textField);//w w w .jav a 2s . c om int result = JOptionPane.showOptionDialog(null, panel, "Enter a Number", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, options1, null); if (result == JOptionPane.YES_OPTION) { JOptionPane.showMessageDialog(null, textField.getText()); } }
From source file:Main.java
public static void main(String... args) throws Exception { JPanel panel = new JPanel(); panel.setOpaque(true);//from w ww. j a va 2 s. c o m panel.setBackground(Color.RED); java.net.URL url = new java.net.URL("http://www.java2s.com/style/download.png"); ImageIcon image = new ImageIcon(url); JLabel label = new JLabel("LABEL", image, JLabel.RIGHT); panel.add(label); JOptionPane.showMessageDialog(null, panel, "Modified JOptionPane : ", JOptionPane.PLAIN_MESSAGE); }
From source file:Main.java
public static void main(String[] args) { JPanel panel = new JPanel(); Box box = Box.createVerticalBox(); for (int i = 0; i < 100; i++) { box.add(new JLabel("Hello!")); }//from ww w . j a va2s .c o m panel.add(box); JTabbedPane tab = new JTabbedPane(); JScrollPane scroll = new JScrollPane(panel); scroll.setPreferredSize(new Dimension(300, 300)); tab.add(scroll, "Panel 1"); JOptionPane.showMessageDialog(null, tab, "Test Tabbed", JOptionPane.PLAIN_MESSAGE); }
From source file:Main.java
public static void main(String[] args) { String[] items = new String[] { "One", "Two", "Three", "Four" }; JList<String> list = new JList<>(items); JFrame f = new JFrame(); f.add(list, BorderLayout.CENTER); JButton btn = new JButton("Get selected"); btn.addActionListener(new ActionListener() { @Override//from w w w. ja va 2s . com public void actionPerformed(ActionEvent e) { JOptionPane.showConfirmDialog(f, "You Selected : " + list.getSelectedValue(), "Display", JOptionPane.PLAIN_MESSAGE); } }); f.add(btn, BorderLayout.SOUTH); f.pack(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); }