List of usage examples for javax.swing JDialog setVisible
public void setVisible(boolean b)
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 . j a v a 2 s . c om JDialog dialog = optionPane.createDialog(null, "TEST"); dialog.setLocation(10, 20); dialog.setVisible(true); System.out.println(optionPane.getInputValue()); }
From source file:AddingButtonWithActionListener.java
public static void main(String[] a) { JFrame frame = new JFrame(); JOptionPane optionPane = new JOptionPane(); optionPane.setMessage("I got an icon and a text label"); optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE); Icon icon = new ImageIcon("yourFile.gif"); JButton jButton = getButton(optionPane, "OK", icon); optionPane.setOptions(new Object[] { jButton }); JDialog dialog = optionPane.createDialog(frame, "Icon/Text Button"); dialog.setVisible(true); }
From source file:JColorChooserWithCustomPreviewPanel.java
public static void main(String[] a) { final JLabel previewLabel = new JLabel("I Love Swing", JLabel.CENTER); previewLabel.setFont(new Font("Serif", Font.BOLD | Font.ITALIC, 48)); previewLabel.setSize(previewLabel.getPreferredSize()); previewLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 1, 0)); JColorChooser colorChooser = new JColorChooser(); colorChooser.setPreviewPanel(previewLabel); JDialog d = colorChooser.createDialog(null, "", true, colorChooser, null, null); d.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JOptionPane pane = new JOptionPane("your message", JOptionPane.ERROR_MESSAGE, JOptionPane.OK_OPTION); JDialog d = pane.createDialog(null, "title"); d.pack();/*from w w w . ja v a 2 s .com*/ d.setModal(false); d.setVisible(true); while (pane.getValue() == JOptionPane.UNINITIALIZED_VALUE) { try { Thread.sleep(100); } catch (InterruptedException ie) { } } System.exit(0); }
From source file:Main.java
public static void main(String[] args) { int TIME_VISIBLE = 3000; JFrame frame1 = new JFrame(); frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame1.setSize(100, 100);/*from w ww . j a va 2s . c o m*/ frame1.setLocation(100, 100); JButton button = new JButton("My Button"); frame1.getContentPane().add(button); button.addActionListener(e -> { JOptionPane pane = new JOptionPane("Message", JOptionPane.INFORMATION_MESSAGE); JDialog dialog = pane.createDialog(null, "Title"); dialog.setModal(false); dialog.setVisible(true); new Timer(TIME_VISIBLE, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.setVisible(false); } }).start(); }); frame1.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { final JFrame parent = new JFrame("Parent Frame"); parent.setLayout(new FlowLayout()); parent.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); parent.setBounds(100, 100, 300, 200); parent.setVisible(true);/*w w w .ja va2 s .c om*/ JDialog dialog1 = new JDialog(parent, "Dialog1 - Modeless Dialog"); dialog1.setBounds(200, 200, 300, 200); dialog1.setVisible(true); JDialog dialog2 = new JDialog(parent, "Dialog2 - Document-Modal Dialog", Dialog.ModalityType.DOCUMENT_MODAL); dialog2.setBounds(300, 300, 300, 200); JDialog dialog3 = new JDialog(dialog2, "Dialog3 - Modeless Dialog"); dialog3.setBounds(400, 400, 300, 200); dialog3.setVisible(true); dialog2.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JPanel gui = new JPanel(new BorderLayout(2, 3)); JPanel buttonConstrsint = new JPanel(new FlowLayout(FlowLayout.CENTER)); JButton getQuotesButton = new JButton("Load"); buttonConstrsint.add(getQuotesButton); gui.add(buttonConstrsint, BorderLayout.NORTH); getQuotesButton.addActionListener(e -> { String[] columnNames = { "First Name", "Last Name", "Sport", "# of Years", "Vegetarian" }; Object[][] data = { { "A", "B", "Snowboarding", new Integer(5), new Boolean(false) }, { "C", "D", "Pool", new Integer(10), new Boolean(false) } }; JTable table = new JTable(data, columnNames); JScrollPane scrollPane = new JScrollPane(table); table.setFillsViewportHeight(true); gui.add(scrollPane, BorderLayout.CENTER); gui.revalidate();/*www. java 2 s. c om*/ gui.repaint(); }); JOptionPane jOptionPane = new JOptionPane(gui); JDialog dialog = jOptionPane.createDialog(new JFrame(), "title"); dialog.setSize(200, 200); dialog.setVisible(true); }
From source file:JOptionPaneDemonstrationLocalized.java
public static void main(String[] argv) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font unicodeFont = new Font("LucidaSans", Font.PLAIN, 12); ResourceBundle bundle = ResourceBundle.getBundle("JOptionPaneResources", Locale.getDefault()); String[] textMessages = new String[3]; textMessages[0] = bundle.getString("Yes"); textMessages[1] = bundle.getString("No"); textMessages[2] = bundle.getString("Cancel"); JOptionPane jop = new JOptionPane(bundle.getString("MessageText"), JOptionPane.ERROR_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, null, textMessages); JDialog jopDialog = jop.createDialog(null, bundle.getString("TitleText")); jop.setFont(unicodeFont);//from ww w . ja va 2s . c o m jopDialog.setVisible(true); Object userSelection = jop.getValue(); }
From source file:SystemColorChooserPanel.java
public static void main(String[] a) { JColorChooser colorChooser = new JColorChooser(); colorChooser.addChooserPanel(new SystemColorChooserPanel()); JDialog d = colorChooser.createDialog(null, "", true, colorChooser, null, null); d.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { int result = JOptionPane.showConfirmDialog(null, "Show over parent?"); for (int i = 1; i < 4; i++) { JFrame f = new JFrame("Frame " + i); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); Component parent = (JOptionPane.OK_OPTION == result ? f : null); f.setSize(400, 300);// ww w.ja v a 2 s. co m f.setLocationByPlatform(true); f.setVisible(true); JDialog d = new JDialog(f); d.setTitle("Dialog " + i); d.setSize(300, 200); d.setLocationRelativeTo(parent); d.setVisible(true); } }