Search in sources :

Example 11 with JDialog

use of javax.swing.JDialog in project smile by haifengl.

the class PlotCanvas method createPropertyDialog.

/**
     * Creates the property dialog.
     * @return the property dialog.
     */
private JDialog createPropertyDialog() {
    Frame frame = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, this);
    JDialog dialog = new JDialog(frame, "Plot Properties", true);
    Action okAction = new PropertyDialogOKAction(dialog);
    Action cancelAction = new PropertyDialogCancelAction(dialog);
    JButton okButton = new JButton(okAction);
    JButton cancelButton = new JButton(cancelAction);
    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new FlowLayout(FlowLayout.TRAILING));
    buttonsPanel.add(okButton);
    buttonsPanel.add(cancelButton);
    buttonsPanel.setBorder(BorderFactory.createEmptyBorder(25, 0, 10, 10));
    ActionMap actionMap = buttonsPanel.getActionMap();
    actionMap.put(cancelAction.getValue(Action.DEFAULT), cancelAction);
    actionMap.put(okAction.getValue(Action.DEFAULT), okAction);
    InputMap inputMap = buttonsPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), cancelAction.getValue(Action.DEFAULT));
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), okAction.getValue(Action.DEFAULT));
    String[] columnNames = { "Property", "Value" };
    if (base.dimension == 2) {
        Object[][] data = { { "Title", title }, { "Title Font", titleFont }, { "Title Color", titleColor }, { "X Axis Title", getAxis(0).getAxisLabel() }, { "X Axis Range", new double[] { base.getLowerBounds()[0], base.getUpperBounds()[0] } }, { "Y Axis Title", getAxis(1).getAxisLabel() }, { "Y Axis Range", new double[] { base.getLowerBounds()[1], base.getUpperBounds()[1] } } };
        propertyTable = new Table(data, columnNames);
    } else {
        Object[][] data = { { "Title", title }, { "Title Font", titleFont }, { "Title Color", titleColor }, { "X Axis Title", getAxis(0).getAxisLabel() }, { "X Axis Range", new double[] { base.getLowerBounds()[0], base.getUpperBounds()[0] } }, { "Y Axis Title", getAxis(1).getAxisLabel() }, { "Y Axis Range", new double[] { base.getLowerBounds()[1], base.getUpperBounds()[1] } }, { "Z Axis Title", getAxis(2).getAxisLabel() }, { "Z Axis Range", new double[] { base.getLowerBounds()[2], base.getUpperBounds()[2] } } };
        propertyTable = new Table(data, columnNames);
    }
    // There is a known issue with JTables whereby the changes made in a
    // cell editor are not committed when focus is lost.
    // This can result in the table staying in 'edit mode' with the stale
    // value in the cell being edited still showing, although the change
    // has not actually been committed to the model.
    //
    // In fact what should happen is for the method stopCellEditing()
    // on CellEditor to be called when focus is lost.
    // So the editor can choose whether to accept the new value and stop
    // editing, or have the editing cancelled without committing.
    // There is a magic property which you have to set on the JTable
    // instance to turn this feature on.
    propertyTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
    propertyTable.setFillsViewportHeight(true);
    JScrollPane tablePanel = new JScrollPane(propertyTable);
    dialog.getContentPane().add(tablePanel, BorderLayout.CENTER);
    dialog.getContentPane().add(buttonsPanel, BorderLayout.SOUTH);
    dialog.pack();
    dialog.setLocationRelativeTo(frame);
    return dialog;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) Frame(java.awt.Frame) AbstractAction(javax.swing.AbstractAction) Action(javax.swing.Action) FlowLayout(java.awt.FlowLayout) JTable(javax.swing.JTable) Table(smile.swing.Table) ActionMap(javax.swing.ActionMap) JButton(javax.swing.JButton) InputMap(javax.swing.InputMap) JDialog(javax.swing.JDialog)

Example 12 with JDialog

use of javax.swing.JDialog in project smile by haifengl.

the class FontChooser method showDialog.

/**
     *  Show font selection dialog.
     *  @param parent Dialog's Parent component.
     *  @return OK_OPTION, CANCEL_OPTION or ERROR_OPTION
     *
     *  @see #OK_OPTION 
     *  @see #CANCEL_OPTION
     *  @see #ERROR_OPTION
     **/
public int showDialog(Component parent) {
    dialogResultValue = ERROR_OPTION;
    JDialog dialog = createDialog(parent);
    dialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            dialogResultValue = CANCEL_OPTION;
        }
    });
    dialog.setVisible(true);
    dialog.dispose();
    dialog = null;
    return dialogResultValue;
}
Also used : WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) JDialog(javax.swing.JDialog)

Example 13 with JDialog

use of javax.swing.JDialog in project binnavi by google.

the class CNodeFunctions method editNodeComments.

/**
   * Shows a dialog to edit the comments of a node.
   * 
   * @param node The node whose comments are edited.
   * @param initialTab The initially visible tab.
   */
public static void editNodeComments(final CGraphModel model, final INaviViewNode node, final InitialTab initialTab) {
    Preconditions.checkNotNull(node, "IE02131: Node argument can not be null");
    final JDialog dialog = getCommentDialog(model, node, initialTab);
    GuiHelper.centerChildToParent(model.getParent(), dialog, true);
    dialog.setVisible(true);
}
Also used : JDialog(javax.swing.JDialog)

Example 14 with JDialog

use of javax.swing.JDialog in project binnavi by google.

the class CColorChooser method showDialog.

public static Color showDialog(final Component parent, final String title, final Color initialColor, final Color[] recentColors) throws HeadlessException {
    final CColorChooser pane = new CColorChooser(initialColor, recentColors);
    final SelectedColorActionListener ok = pane.new SelectedColorActionListener();
    final JDialog dlg = createDialog(parent, title, true, pane, ok, null);
    dlg.setVisible(true);
    dlg.dispose();
    return ok.getColor();
}
Also used : JDialog(javax.swing.JDialog)

Example 15 with JDialog

use of javax.swing.JDialog in project jdk8u_jdk by JetBrains.

the class DimensionEncapsulation method run.

@Override
public void run() {
    runTest(new Panel());
    runTest(new Button());
    runTest(new Checkbox());
    runTest(new Canvas());
    runTest(new Choice());
    runTest(new Label());
    runTest(new Scrollbar());
    runTest(new TextArea());
    runTest(new TextField());
    runTest(new Dialog(new JFrame()));
    runTest(new Frame());
    runTest(new Window(new JFrame()));
    runTest(new FileDialog(new JFrame()));
    runTest(new List());
    runTest(new ScrollPane());
    runTest(new JFrame());
    runTest(new JDialog(new JFrame()));
    runTest(new JWindow(new JFrame()));
    runTest(new JLabel("hi"));
    runTest(new JMenu());
    runTest(new JTree());
    runTest(new JTable());
    runTest(new JMenuItem());
    runTest(new JCheckBoxMenuItem());
    runTest(new JToggleButton());
    runTest(new JSpinner());
    runTest(new JSlider());
    runTest(Box.createVerticalBox());
    runTest(Box.createHorizontalBox());
    runTest(new JTextField());
    runTest(new JTextArea());
    runTest(new JTextPane());
    runTest(new JPasswordField());
    runTest(new JFormattedTextField());
    runTest(new JEditorPane());
    runTest(new JButton());
    runTest(new JColorChooser());
    runTest(new JFileChooser());
    runTest(new JCheckBox());
    runTest(new JInternalFrame());
    runTest(new JDesktopPane());
    runTest(new JTableHeader());
    runTest(new JLayeredPane());
    runTest(new JRootPane());
    runTest(new JMenuBar());
    runTest(new JOptionPane());
    runTest(new JRadioButton());
    runTest(new JRadioButtonMenuItem());
    runTest(new JPopupMenu());
    //runTest(new JScrollBar()); --> don't test defines max and min in
    // terms of preferred
    runTest(new JScrollPane());
    runTest(new JViewport());
    runTest(new JSplitPane());
    runTest(new JTabbedPane());
    runTest(new JToolBar());
    runTest(new JSeparator());
    runTest(new JProgressBar());
    if (!failures.isEmpty()) {
        System.out.println("These classes failed");
        for (final Component failure : failures) {
            System.out.println(failure.getClass());
        }
        throw new RuntimeException("Test failed");
    }
}
Also used : JDesktopPane(javax.swing.JDesktopPane) Choice(java.awt.Choice) JTextArea(javax.swing.JTextArea) TextArea(java.awt.TextArea) JTextArea(javax.swing.JTextArea) Label(java.awt.Label) JLabel(javax.swing.JLabel) JTableHeader(javax.swing.table.JTableHeader) JToggleButton(javax.swing.JToggleButton) JToggleButton(javax.swing.JToggleButton) Button(java.awt.Button) JRadioButton(javax.swing.JRadioButton) JButton(javax.swing.JButton) JFrame(javax.swing.JFrame) Checkbox(java.awt.Checkbox) JDialog(javax.swing.JDialog) FileDialog(java.awt.FileDialog) Dialog(java.awt.Dialog) JTextField(javax.swing.JTextField) TextField(java.awt.TextField) JFormattedTextField(javax.swing.JFormattedTextField) JSlider(javax.swing.JSlider) ArrayList(java.util.ArrayList) List(java.awt.List) Canvas(java.awt.Canvas) JWindow(javax.swing.JWindow) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JFileChooser(javax.swing.JFileChooser) JPasswordField(javax.swing.JPasswordField) ScrollPane(java.awt.ScrollPane) JScrollPane(javax.swing.JScrollPane) JTable(javax.swing.JTable) JSpinner(javax.swing.JSpinner) JSplitPane(javax.swing.JSplitPane) JColorChooser(javax.swing.JColorChooser) JInternalFrame(javax.swing.JInternalFrame) JDialog(javax.swing.JDialog) JFrame(javax.swing.JFrame) Frame(java.awt.Frame) JInternalFrame(javax.swing.JInternalFrame) JRadioButton(javax.swing.JRadioButton) JLayeredPane(javax.swing.JLayeredPane) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) JTextPane(javax.swing.JTextPane) JMenuItem(javax.swing.JMenuItem) Component(java.awt.Component) Scrollbar(java.awt.Scrollbar) Window(java.awt.Window) JWindow(javax.swing.JWindow) JScrollPane(javax.swing.JScrollPane) JViewport(javax.swing.JViewport) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) JToolBar(javax.swing.JToolBar) JPopupMenu(javax.swing.JPopupMenu) Panel(java.awt.Panel) JEditorPane(javax.swing.JEditorPane) JRootPane(javax.swing.JRootPane) FileDialog(java.awt.FileDialog) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Aggregations

JDialog (javax.swing.JDialog)141 JButton (javax.swing.JButton)65 JPanel (javax.swing.JPanel)50 ActionEvent (java.awt.event.ActionEvent)42 JLabel (javax.swing.JLabel)35 ActionListener (java.awt.event.ActionListener)30 BorderLayout (java.awt.BorderLayout)24 JScrollPane (javax.swing.JScrollPane)24 JFrame (javax.swing.JFrame)20 Dimension (java.awt.Dimension)18 BoxLayout (javax.swing.BoxLayout)18 JCheckBox (javax.swing.JCheckBox)15 FlowLayout (java.awt.FlowLayout)14 AbstractAction (javax.swing.AbstractAction)14 JOptionPane (javax.swing.JOptionPane)13 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)11 WindowEvent (java.awt.event.WindowEvent)11 IOException (java.io.IOException)10 JProgressBar (javax.swing.JProgressBar)10 WindowAdapter (java.awt.event.WindowAdapter)9