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;
}
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;
}
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);
}
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();
}
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");
}
}
Aggregations