public int showDialog() { panel = new JPanel(new GridBagLayout()); double lower = Double.NEGATIVE_INFINITY; double upper = Double.POSITIVE_INFINITY; if (parameter.isZeroOne) { lower = 0.0; upper = 1.0; } else if (parameter.isNonNegative) { lower = 0.0; } panel = new JPanel(new GridBagLayout()); setupComponents(); JOptionPane optionPane = new JOptionPane( panel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null); optionPane.setBorder(new EmptyBorder(12, 12, 12, 12)); final JDialog dialog = optionPane.createDialog(frame, "Linked Parameter Setup"); priorSettingsPanel.setDialog(dialog); priorSettingsPanel.setParameter(parameter); if (OSType.isMac()) { dialog.setMinimumSize(new Dimension(dialog.getBounds().width, 300)); } else { Toolkit tk = Toolkit.getDefaultToolkit(); Dimension d = tk.getScreenSize(); if (d.height < 700 && panel.getHeight() > 450) { dialog.setSize(new Dimension(panel.getWidth() + 100, 550)); } else { // setSize because optionsPanel is shrunk in dialog dialog.setSize(new Dimension(panel.getWidth() + 100, panel.getHeight() + 100)); } // System.out.println("panel width = " + panel.getWidth()); // System.out.println("panel height = " + panel.getHeight()); } dialog.pack(); dialog.setResizable(true); dialog.setVisible(true); int result = JOptionPane.CANCEL_OPTION; Integer value = (Integer) optionPane.getValue(); if (value != null && value != -1) { result = value; } return result; }
public int showDialog() { options = new OptionsPanel(6, 6); options.addComponent(autoScaleCheck); JPanel panel = new JPanel(); panel.setLayout(new FlowLayout()); panel.add(fromLabel); panel.add(fromNumberField); panel.add(toLabel); panel.add(toNumberField); options.addComponent(panel); JPanel panel1 = new JPanel(); panel1.setLayout(new FlowLayout()); panel1.add(new JLabel("Width from:")); panel1.add(fromWidthField); panel1.add(new JLabel("to:")); panel1.add(toWidthField); options.addComponent(panel1); JOptionPane optionPane = new JOptionPane( options, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null); optionPane.setBorder(new EmptyBorder(12, 12, 12, 12)); final JDialog dialog = optionPane.createDialog(frame, "Setup colour range"); dialog.pack(); autoScaleCheck.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean enabled = !autoScaleCheck.isSelected(); fromLabel.setEnabled(enabled); fromNumberField.setEnabled(enabled); toLabel.setEnabled(enabled); toNumberField.setEnabled(enabled); } }); dialog.setVisible(true); int result = JOptionPane.CANCEL_OPTION; Integer value = (Integer) optionPane.getValue(); if (value != null && value.intValue() != -1) { result = value.intValue(); } return result; }
public int showDialog(JChart chart) { JOptionPane optionPane = new JOptionPane( optionPanel, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null, null); optionPane.setBorder(new EmptyBorder(12, 12, 12, 12)); Axis xAxis = chart.getXAxis(); Axis yAxis = chart.getYAxis(); if (canLogXAxis) { logXAxis.setSelected(xAxis instanceof LogAxis); } if (canLogYAxis) { logYAxis.setSelected(yAxis instanceof LogAxis); } if (!manualXAxis.isSelected()) { minXValue.setValue(xAxis.getMinAxis()); maxXValue.setValue(xAxis.getMaxAxis()); } if (!manualYAxis.isSelected()) { minYValue.setValue(yAxis.getMinAxis()); maxYValue.setValue(yAxis.getMaxAxis()); } final JDialog dialog = optionPane.createDialog(frame, "Setup Chart"); dialog.pack(); dialog.setVisible(true); final Integer value = (Integer) optionPane.getValue(); final int result = (value != null && value != -1) ? value : JOptionPane.CANCEL_OPTION; if (result == JOptionPane.OK_OPTION) { applySettings(chart); } return result; }
public boolean showDialog(String title) { JOptionPane optionPane = new JOptionPane( optionPanel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, new String[] {"Run", "Quit"}, "Run"); optionPane.setBorder(new EmptyBorder(12, 12, 12, 12)); final JDialog dialog = optionPane.createDialog(frame, title); // dialog.setResizable(true); dialog.pack(); dialog.setVisible(true); return (optionPane.getValue() != null ? optionPane.getValue().equals("Run") : false); }