List of usage examples for javax.swing JOptionPane showMessageDialog
public static void showMessageDialog(Component parentComponent, Object message) throws HeadlessException
From source file:Main.java
public static void main(String[] args) { JCheckBox checkBox = new JCheckBox("Enabled", true); checkBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (checkBox.isEnabled()) checkBox.setEnabled(false); else/* www .ja v a 2 s. c om*/ checkBox.setEnabled(true); } }); JOptionPane.showMessageDialog(null, checkBox); }
From source file:Main.java
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); String[] fonts = ge.getAvailableFontFamilyNames(); JComboBox<String> fontChooser = new JComboBox<>(fonts); fontChooser.setRenderer(new FontCellRenderer()); JOptionPane.showMessageDialog(null, fontChooser); }
From source file:Main.java
public static void main(String[] args) { String pt1 = "<html><body width='"; String pt2 = "'><h1>Label Width</h1>" + "<p>Many Swing components support HTML 3.2 &" + " (simple) CSS. This is a new line.<br><br>" + "<p>The body width in this text is set to " + ""; String pt3 = " pixels." + ""; JPanel p = new JPanel(new BorderLayout()); int width = 175; String s = pt1 + width + pt2 + width + pt3; JOptionPane.showMessageDialog(null, s); }
From source file:ShowAction.java
public static void main(final String args[]) { JButton bn = new JButton(new ShowAction()); JOptionPane.showMessageDialog(null, bn); }
From source file:Main.java
public static void main(String[] args) { List<String> list = new ArrayList<>(); for (int i = 0; i < 30; i++) { list.add("Hello, World " + i); }//from w w w . j a v a 2 s. c o m JScrollPane pane = new JScrollPane(new JList(list.toArray())) { @Override public Dimension getPreferredSize() { return new Dimension(200, 250); } }; JOptionPane.showMessageDialog(null, pane); }
From source file:Main.java
public static void main(String[] args) throws Exception { File archivo = new File("c:/Java_Dev/run.bat"); FileReader fr = new FileReader(archivo); BufferedReader br = new BufferedReader(fr); Vector<String> lines = new Vector<String>(); String line;/* ww w. j a va 2 s . com*/ while ((line = br.readLine()) != null) { lines.add(line); } JOptionPane.showMessageDialog(null, new JScrollPane(new JList(lines))); fr.close(); }
From source file:Main.java
public static void main(final String args[]) { JButton button = new JButton(); // Icon will appear gray button.setEnabled(false);/*from w w w . j a v a 2 s. c o m*/ // Set a disabled version of icon Icon disabledIcon = new ImageIcon("d.gif"); button.setDisabledIcon(disabledIcon); // To remove the disabled version of the icon, set to null button.setDisabledIcon(null); button.setDisabledIcon(new ImageIcon("icon.gif")); JOptionPane.showMessageDialog(null, button); }
From source file:Main.java
public static void main(String[] args) { JLabel l = new JLabel("Text"); l.setBorder(new ThreeDimensionalBorder(Color.BLACK, 200, 5)); JOptionPane.showMessageDialog(null, l); }
From source file:Main.java
public static void main(String[] args) { JButton button = new JButton("Test"); ButtonModel model = button.getModel(); model.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { System.out.println("Armed: " + model.isArmed() + " Enabled: " + model.isEnabled() + " Pressed: " + model.isPressed()); }//ww w. ja v a2 s .co m }); JOptionPane.showMessageDialog(null, button); }
From source file:Main.java
public static void main(final String args[]) { JButton button = new JButton("Text Button"); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { String command = actionEvent.getActionCommand(); System.out.println("Selected: " + command); }//from www . ja v a2 s . c o m }; button.setActionCommand("First"); button.addActionListener(actionListener); JOptionPane.showMessageDialog(null, button); }