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 Main() throws HeadlessException { setSize(200, 200);/* w w w.j a v a 2s .c o m*/ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton button1 = new JButton("Message dialog"); button1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog((Component) e.getSource(), "Thank you!"); } }); JButton button2 = new JButton("Input dialog"); button2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String text = JOptionPane.showInputDialog((Component) e.getSource(), "What is your name?"); if (text != null && !text.equals("")) { JOptionPane.showMessageDialog((Component) e.getSource(), "Hello " + text); } } }); JButton button3 = new JButton("Yes no dialog"); button3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int result = JOptionPane.showConfirmDialog((Component) e.getSource(), "Close this application?"); if (result == JOptionPane.YES_OPTION) { System.exit(0); } else if (result == JOptionPane.NO_OPTION) { System.out.println("Do nothing"); } } }); setLayout(new FlowLayout(FlowLayout.CENTER)); getContentPane().add(button1); getContentPane().add(button2); getContentPane().add(button3); }
From source file:Main.java
Main() { getRootPane().setGlassPane(new JComponent() { public void paintComponent(Graphics g) { g.setColor(new Color(0, 0, 0, 100)); g.fillRect(0, 0, getWidth(), getHeight()); super.paintComponent(g); }/*from ww w .j av a2 s. c o m*/ }); JButton popDialog = new JButton("Block Frame"); popDialog.addActionListener(e -> { getRootPane().getGlassPane().setVisible(true); JOptionPane.showMessageDialog(Main.this, "Shady!"); getRootPane().getGlassPane().setVisible(false); }); setContentPane(popDialog); pack(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(350, 180); }
From source file:Main.java
public Main(final Frame owner) { super(owner); JPanel pnl = new JPanel(new BorderLayout()); pnl.add(new JLabel("Click outside this dialog in the parent frame to close it"), BorderLayout.NORTH); JButton btn = new JButton("Click Me"); btn.addActionListener(e -> JOptionPane.showMessageDialog(Main.this, "New Child Window")); pnl.add(btn, BorderLayout.CENTER); this.setContentPane(pnl); this.pack();/*from w w w. ja va 2s .c o m*/ this.setLocationRelativeTo(owner); this.setAlwaysOnTop(true); this.addWindowFocusListener(new WindowFocusListener() { public void windowGainedFocus(WindowEvent e) { } public void windowLostFocus(WindowEvent e) { if (SwingUtilities.isDescendingFrom(e.getOppositeWindow(), Main.this)) { return; } Main.this.setVisible(false); } }); }
From source file:Main.java
private WindowAdapter getWindowAdapter() { return new WindowAdapter() { @Override// ww w . j av a2 s .c o m public void windowClosing(WindowEvent we) { super.windowClosing(we); JOptionPane.showMessageDialog(frame, "Cant Exit"); } @Override public void windowIconified(WindowEvent we) { frame.setState(JFrame.NORMAL); JOptionPane.showMessageDialog(frame, "Cant Minimize"); } }; }
From source file:com.raphfrk.craftproxyclient.gui.GUIManager.java
public static void messageBox(String message) { JOptionPane.showMessageDialog(CraftProxyClient.getGUI(), message); }
From source file:Main.java
Main() { JPanel p = new JPanel(new BorderLayout(2, 2)); JTextField find = new JTextField("food:pizza"); find.addActionListener(e -> {/*from w w w. ja v a2 s . c om*/ boolean found = findText(find.getText()); System.out.println(find.getText() + " found " + found); }); p.add(find, BorderLayout.PAGE_START); tree.setVisibleRowCount(8); for (int row = tree.getRowCount(); row >= 0; row--) { tree.expandRow(row); } p.add(new JScrollPane(tree), BorderLayout.CENTER); JOptionPane.showMessageDialog(null, p); }
From source file:Main.java
public Main() { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel jl = new JLabel("Try with formatted text field "); Locale local1 = new Locale("en", "US"); int minFra = 0; int maxFra = 3; jft = setFormat(jft, local1, minFra, maxFra); jft.setMaximumSize(new Dimension(100, 20)); jft.setMinimumSize(new Dimension(100, 20)); jft.setPreferredSize(new Dimension(100, 20)); frame.add(jl);//from w w w . j a v a 2 s .c o m frame.add(jft, BorderLayout.NORTH); jb.addActionListener(e -> JOptionPane.showMessageDialog(jb, "nel text Box : " + jft.getText())); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public Main() { made_list.setModel(new DefaultListModel()); for (String element : elements) { ((DefaultListModel) made_list.getModel()).addElement(element); }//from w w w .j a va2 s.c o m JButton removeItemBtn = new JButton("Remove Item"); removeItemBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removeActionPerformed(e); } }); JPanel panel = new JPanel(); panel.add(new JScrollPane(made_list)); panel.add(removeItemBtn); JOptionPane.showMessageDialog(null, panel); }
From source file:Main.java
public Main() { this.setLayout(new FlowLayout()); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton processButton = new JButton("Start"); JButton helloButton = new JButton("Hello"); processButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { MyTask process = new MyTask(); try { process.execute();/* w ww .ja v a 2 s.co m*/ } catch (Exception e) { e.printStackTrace(); } } }); helloButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(null, "Hello There"); } }); this.getContentPane().add(processButton); this.getContentPane().add(helloButton); this.pack(); setVisible(true); }
From source file:control.LoadControler.java
public static Set<File> listFilesForFolder(final File folder) { Set<File> set = new HashSet<>(); // JOptionPane.showMessageDialog(null, "Chargement :\n" + folder); // DEBUG try {// w w w .j av a 2s . c o m for (final File fileEntry : folder.listFiles()) { if (fileEntry.isDirectory()) { listFilesForFolder(fileEntry); } else { set.add(fileEntry); } } } catch (NullPointerException e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, e); } return set; }