List of usage examples for javax.swing JOptionPane JOptionPane
public JOptionPane(Object message)
JOptionPane
to display a message using the plain-message message type and the default options delivered by the UI. From source file:savant.export.ExportPlugin.java
private void setupGUI(JPanel panel) { panel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); //create padding gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 0;// ww w .j a v a 2 s . c om gbc.weighty = 0; gbc.gridx = 0; gbc.gridy = 0; JPanel fill1 = new JPanel(); fill1.setPreferredSize(new Dimension(10, 10)); panel.add(fill1, gbc); //create path chooser JLabel htmlLabel = new JLabel( "<html>Choose folder to save files.<br>An html index file will be created here.</html>"); gbc.gridwidth = 2; gbc.gridx = 1; gbc.gridy = 1; panel.add(htmlLabel, gbc); pf = new PathField(JFileChooser.OPEN_DIALOG, false, true); gbc.gridx = 1; gbc.gridy = 2; panel.add(pf, gbc); //create runExport button JButton runButton = new JButton("Run"); runButton.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { exportThread = new Thread("Export Plugin") { @Override public void run() { try { runTool(); } catch (InterruptedException ex) { //TODO: deal with exception? LOG.error("Export interrupted.", ex); } } }; exportThread.start(); //create progress dialog Object[] options = { "Cancel" }; progressPanel = new JOptionPane(" Running Export: 1"); progressPanel.setOptions(options); progressDialog = progressPanel.createDialog("Export in progress"); progressDialog.setVisible(true); if (progressPanel.getValue().equals("Cancel")) { exportCancelled = true; } } }); gbc.weightx = 0; gbc.gridwidth = 1; gbc.weightx = 0; gbc.weighty = 0; gbc.gridx = 1; gbc.gridy = 3; panel.add(runButton, gbc); //create output label outputLabel = new JLabel(); Font f = outputLabel.getFont(); outputLabel.setFont(f.deriveFont(f.getStyle() ^ Font.BOLD)); gbc.gridx = 2; gbc.gridy = 3; panel.add(outputLabel, gbc); //create padding JPanel fill2 = new JPanel(); fill2.setPreferredSize(new Dimension(10, 10)); gbc.weightx = 1.0; gbc.gridwidth = 1; gbc.gridx = 2; gbc.gridy = 3; panel.add(fill2, gbc); JPanel fill3 = new JPanel(); fill3.setPreferredSize(new Dimension(10, 10)); gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.gridwidth = 2; gbc.gridx = 0; gbc.gridy = 4; panel.add(fill3, gbc); }