Search in sources :

Example 6 with JOptionPane

use of javax.swing.JOptionPane 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)

Example 7 with JOptionPane

use of javax.swing.JOptionPane in project ceylon-compiler by ceylon.

the class SelectToolTask method showGUI.

void showGUI(Properties fileProps) {
    Properties guiProps = new Properties(fileProps);
    JOptionPane p = createPane(guiProps);
    p.createDialog("Select Tool").setVisible(true);
    toolName = (String) toolChoice.getSelectedItem();
    toolArgs = argsField.getText();
    if (defaultCheck.isSelected()) {
        if (toolName.equals("")) {
            fileProps.remove("tool.name");
        } else {
            fileProps.put("tool.name", toolName);
            fileProps.put(toolName + ".args", toolArgs);
        }
        writeProperties(propertyFile, fileProps);
    }
}
Also used : Properties(java.util.Properties) JOptionPane(javax.swing.JOptionPane)

Example 8 with JOptionPane

use of javax.swing.JOptionPane in project processdash by dtuma.

the class TaskScheduleChooser method getTemplateName.

protected String getTemplateName(Object parent, String title, String prompt, String initialTaskName, boolean showRollupOptions) {
    String taskName = "";
    Object message = prompt, button;
    Object[] options;
    JComboBox rollupOption = null;
    if (showRollupOptions) {
        String[] rollupOptions = new String[2];
        rollupOptions[0] = resources.getString("Create_Schedule_Option");
        rollupOptions[1] = resources.getString("Create_Rollup_Option");
        rollupOption = new JComboBox(rollupOptions);
        options = new Object[] { rollupOption, new JLabel("      "), OK, CANCEL };
    } else
        options = new Object[] { OK, CANCEL };
    JTextField inputField = new JTextField(initialTaskName);
    inputField.selectAll();
    new JOptionPaneActionHandler(OK).install(inputField);
    Component parentComponent = null;
    if (parent instanceof Component)
        parentComponent = (Component) parent;
    while (true) {
        JOptionPane optionPane = new JOptionPane(new Object[] { message, inputField }, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options);
        optionPane.createDialog(parentComponent, title).setVisible(true);
        button = optionPane.getValue();
        if (!OK.equals(button))
            // user cancel
            return null;
        taskName = (String) inputField.getText();
        taskName = taskName.trim();
        String errorMessage = checkNewTemplateName(taskName, dash.getData());
        if (errorMessage == null)
            break;
        else
            message = new String[] { errorMessage, prompt };
    }
    if (rollupOption != null && rollupOption.getSelectedIndex() == 1)
        taskName = ROLLUP_PREFIX + taskName;
    return taskName;
}
Also used : JOptionPaneActionHandler(net.sourceforge.processdash.ui.lib.JOptionPaneActionHandler) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) Component(java.awt.Component) JOptionPane(javax.swing.JOptionPane)

Example 9 with JOptionPane

use of javax.swing.JOptionPane in project processdash by dtuma.

the class TaskDependencyCellEditor method buildUIComponents.

private void buildUIComponents(Map iconMap) {
    // first, create the button we'll use as our cell editor
    button = new JButton();
    button.setBackground(Color.white);
    button.setFont(UIManager.getFont("TextField.font"));
    button.setBorderPainted(false);
    button.setMargin(new Insets(0, 0, 0, 0));
    button.addKeyListener(EventHandler.create(KeyListener.class, button, "doClick"));
    button.addActionListener((ActionListener) EventHandler.create(ActionListener.class, this, "buttonClicked"));
    // now, create the components we'll show in the dialog.
    List components = new LinkedList();
    pathLabel = new JLabel("path label");
    components.add(pathLabel);
    components.add(Box.createRigidArea(new Dimension(5, 5)));
    dependencies = new DependencyTableModel();
    dependencyTable = new JTable(dependencies);
    dependencyTable.setDefaultRenderer(Object.class, new TaskDependencyCellRenderer());
    scrollPane = new JScrollPane(dependencyTable);
    components.add(scrollPane);
    components.add(Box.createRigidArea(new Dimension(5, 5)));
    taskTree = new WBSJTable(dependencySource.getTaskTree(), iconMap);
    taskTree.setEditingEnabled(false);
    AddAction addAction = new AddAction(taskTree);
    RemoveAction removeAction = new RemoveAction(dependencyTable);
    SaveChangesAction saveAction = new SaveChangesAction();
    // Configure key and mouse bindings for convenience
    bindKeys(dependencyTable, new TransferFocusAction(taskTree), "TAB");
    bindKeys(dependencyTable, removeAction, "BACK_SPACE", "DELETE", "SUBTRACT");
    bindKeys(dependencyTable, saveAction, "ENTER");
    bindKeys(taskTree, new TransferFocusAction(dependencyTable), "TAB");
    bindKeys(taskTree, addAction, "SPACE", "INSERT", "ADD");
    bindKeys(taskTree, saveAction, "ENTER");
    taskTree.getInputMap().put(KeyStroke.getKeyStroke("LEFT"), "collapseTree");
    taskTree.getInputMap().put(KeyStroke.getKeyStroke("RIGHT"), "expandTree");
    taskTree.addMouseListener(new WBSClickHandler(addAction));
    Box b = Box.createHorizontalBox();
    b.add(Box.createHorizontalGlue());
    b.add(new JButton(addAction));
    b.add(Box.createHorizontalGlue());
    b.add(new JButton(removeAction));
    b.add(Box.createHorizontalGlue());
    components.add(b);
    components.add(Box.createRigidArea(new Dimension(5, 5)));
    JScrollPane sp = new JScrollPane(taskTree);
    sp.setPreferredSize(new Dimension(300, 200));
    components.add(sp);
    components.add(new JOptionPaneTweaker.GrabFocus(taskTree));
    optionPane = new JOptionPane(components.toArray(), JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
// we can't actually create the dialog yet, because we don't know
// who the parent window will be.
}
Also used : JScrollPane(javax.swing.JScrollPane) JOptionPaneTweaker(net.sourceforge.processdash.ui.lib.JOptionPaneTweaker) Insets(java.awt.Insets) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Box(javax.swing.Box) Dimension(java.awt.Dimension) JOptionPane(javax.swing.JOptionPane) LinkedList(java.util.LinkedList) JTable(javax.swing.JTable) KeyListener(java.awt.event.KeyListener) LinkedList(java.util.LinkedList) List(java.util.List)

Example 10 with JOptionPane

use of javax.swing.JOptionPane in project languagetool by languagetool-org.

the class LanguageManagerDialog method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (e.getSource() == addButton) {
        Configuration config;
        try {
            config = new Configuration(null);
        } catch (IOException e1) {
            throw new RuntimeException(e1);
        }
        File initialDir;
        File ruleFile;
        if (config.getExternalRuleDirectory() != null) {
            initialDir = new File(config.getExternalRuleDirectory());
            if (initialDir.isDirectory()) {
                ruleFile = Tools.openFileDialog(owner, new XMLFileFilter(), initialDir);
            } else {
                ruleFile = Tools.openFileDialog(owner, new XMLFileFilter());
            }
        } else {
            ruleFile = Tools.openFileDialog(owner, new XMLFileFilter());
        }
        if (ruleFile == null) {
            // dialog was canceled
            return;
        }
        config.setExternalRuleDirectory(ruleFile.getParent());
        try {
            config.saveConfiguration(null);
        } catch (IOException e1) {
            throw new RuntimeException(e1);
        }
        if (!ruleFiles.contains(ruleFile)) {
            ruleFiles.add(ruleFile);
            list.setListData(ruleFiles.toArray(new File[ruleFiles.size()]));
        } else {
            JOptionPane jop = new JOptionPane();
            JOptionPane.showMessageDialog(jop, messages.getString("guiDuplicate"), messages.getString("guiWarning"), JOptionPane.WARNING_MESSAGE);
        }
    } else if (e.getSource() == removeButton) {
        if (list.getSelectedIndex() != -1) {
            ruleFiles.remove(list.getSelectedIndex());
            list.setListData(ruleFiles.toArray(new File[ruleFiles.size()]));
        }
    } else if (e.getSource() == closeButton) {
        dialog.setVisible(false);
    } else {
        throw new IllegalArgumentException("Don't know how to handle " + e);
    }
}
Also used : IOException(java.io.IOException) File(java.io.File) JOptionPane(javax.swing.JOptionPane)

Aggregations

JOptionPane (javax.swing.JOptionPane)19 JDialog (javax.swing.JDialog)12 JLabel (javax.swing.JLabel)10 JButton (javax.swing.JButton)6 JPanel (javax.swing.JPanel)6 JTextField (javax.swing.JTextField)5 JComboBox (javax.swing.JComboBox)4 Component (java.awt.Component)3 Dimension (java.awt.Dimension)3 BoxLayout (javax.swing.BoxLayout)3 JCheckBox (javax.swing.JCheckBox)3 BorderLayout (java.awt.BorderLayout)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 ArrayList (java.util.ArrayList)2 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)2 JColorChooser (javax.swing.JColorChooser)2 JFrame (javax.swing.JFrame)2 JScrollPane (javax.swing.JScrollPane)2 JTable (javax.swing.JTable)2