Search in sources :

Example 91 with JDialog

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

the class QuickSelectTaskAction method selectTask.

private void selectTask() {
    if (taskProvider == null || activeTaskModel == null)
        throw new IllegalStateException("Object not yet initialized");
    TreeTableModel tasks = taskProvider.getTaskSelectionChoices();
    final JFilterableTreeComponent selector = new JFilterableTreeComponent(tasks, resources.getString("Choose_Task.Find"), false);
    final Object nodeToSelect = taskProvider.getTreeNodeForPath(activeTaskModel.getPath());
    loadPrefs(selector);
    selector.setMatchEntirePath(true);
    TaskCompletionRenderer rend = null;
    if (parentComponent instanceof DashboardContext)
        rend = new TaskCompletionRenderer(selector, (DashboardContext) parentComponent);
    new JOptionPaneActionHandler().install(selector);
    Object[] message = new Object[] { resources.getString("Choose_Task.Prompt"), selector, new JOptionPaneTweaker.MakeResizable(), new JOptionPaneTweaker.GrabFocus(selector.getFilterTextField()), new JOptionPaneTweaker(50) {

        public void doTweak(JDialog dialog) {
            if (nodeToSelect != null)
                selector.setAnchorSelectedNode(nodeToSelect);
        }
    } };
    int userChoice = JOptionPane.showConfirmDialog(parentComponent, message, resources.getString("Choose_Task.Title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    savePrefs(selector);
    if (rend != null)
        rend.dispose();
    if (userChoice != JOptionPane.OK_OPTION)
        return;
    Object newTask = selector.getSelectedLeaf();
    if (newTask == null)
        return;
    String newPath = taskProvider.getPathForTreeNode(newTask);
    if (StringUtils.hasValue(newPath))
        activeTaskModel.setPath(newPath);
}
Also used : DashboardContext(net.sourceforge.processdash.DashboardContext) JOptionPaneTweaker(net.sourceforge.processdash.ui.lib.JOptionPaneTweaker) JOptionPaneActionHandler(net.sourceforge.processdash.ui.lib.JOptionPaneActionHandler) TreeTableModel(net.sourceforge.processdash.ui.lib.TreeTableModel) JFilterableTreeComponent(net.sourceforge.processdash.ui.lib.JFilterableTreeComponent) JDialog(javax.swing.JDialog)

Example 92 with JDialog

use of javax.swing.JDialog in project jgnash by ccavanaugh.

the class ConsoleDialog method show.

public static void show() {
    if (dialog == null) {
        // only one visible window
        init();
        ResourceBundle rb = ResourceUtils.getBundle();
        JButton copyButton = new JButton(rb.getString("Button.CopyToClip"));
        copyButton.addActionListener(e -> {
            if (console != null) {
                console.selectAll();
                console.copy();
            }
        });
        JButton gcButton = new JButton(rb.getString("Button.ForceGC"));
        gcButton.addActionListener(e -> System.gc());
        JButton heapButton = new JButton(rb.getString("Button.CreateHeapDump"));
        heapButton.addActionListener(e -> {
            if (console != null) {
                dumpHeap();
            }
        });
        dialog = new JDialog(UIApplication.getFrame(), Dialog.ModalityType.MODELESS);
        dialog.setTitle(rb.getString("Title.Console"));
        dialog.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent evt) {
                /* force the shut down to the end of the event thread.
                     * Lets other listeners do their job */
                EventQueue.invokeLater(() -> {
                    synchronized (consoleLock) {
                        ConsoleDialog.close();
                    }
                });
            }
        });
        synchronized (consoleLock) {
            console = new JTextArea();
            console.setEditable(false);
            // set a mono spaced font to preserve spacing
            console.setFont(new Font("Monospaced", Font.PLAIN, console.getFont().getSize()));
        }
        JPanel panel = new JPanel();
        panel.setBorder(Borders.DIALOG);
        panel.setLayout(new BorderLayout());
        panel.add(new MemoryMonitor(), BorderLayout.NORTH);
        panel.add(new JScrollPane(console), BorderLayout.CENTER);
        JPanel buttonPanel = StaticUIMethods.buildRightAlignedBar(heapButton, gcButton, copyButton);
        buttonPanel.setBorder(new EmptyBorder(10, 0, 10, 0));
        panel.add(buttonPanel, BorderLayout.SOUTH);
        dialog.getContentPane().add(panel, BorderLayout.CENTER);
        dialog.pack();
        // Minimum size
        dialog.setMinimumSize(dialog.getSize());
        dialog.setFocusableWindowState(false);
        dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        DialogUtils.addBoundsListener(dialog);
        dialog.setVisible(true);
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) JTextArea(javax.swing.JTextArea) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) Font(java.awt.Font) MemoryMonitor(jgnash.ui.components.MemoryMonitor) BorderLayout(java.awt.BorderLayout) WindowEvent(java.awt.event.WindowEvent) ResourceBundle(java.util.ResourceBundle) EmptyBorder(javax.swing.border.EmptyBorder) JDialog(javax.swing.JDialog)

Example 93 with JDialog

use of javax.swing.JDialog in project jgnash by ccavanaugh.

the class AboutDialog method showDialog.

public static void showDialog(final Frame parent) {
    EventQueue.invokeLater(() -> {
        JDialog dlg = new AboutDialog(parent, false);
        dlg.setVisible(true);
    });
}
Also used : JDialog(javax.swing.JDialog)

Example 94 with JDialog

use of javax.swing.JDialog in project Fling by entertailion.

the class FlingFrame method createProgressDialog.

/**
	 * Create a progress indicator
	 */
private void createProgressDialog() {
    progressDialog = new JDialog(this, resourceBundle.getString("progress.title"), true);
    JProgressBar progressBar = new JProgressBar(0, 100);
    progressBar.setStringPainted(true);
    progressBar.setIndeterminate(true);
    progressDialog.add(BorderLayout.CENTER, progressBar);
    progressDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    progressDialog.setSize(300, 75);
    progressDialog.setLocationRelativeTo(this);
}
Also used : JProgressBar(javax.swing.JProgressBar) JDialog(javax.swing.JDialog)

Example 95 with JDialog

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

the class FontChooser method createDialog.

private JDialog createDialog(Component parent) {
    Frame frame = parent instanceof Frame ? (Frame) parent : (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);
    JDialog dialog = new JDialog(frame, getMessage("SelectFont"), true);
    Action okAction = new DialogOKAction(dialog);
    Action cancelAction = new DialogCancelAction(dialog);
    JButton okButton = new JButton(okAction);
    okButton.setFont(DEFAULT_FONT);
    JButton cancelButton = new JButton(cancelAction);
    cancelButton.setFont(DEFAULT_FONT);
    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new GridLayout(2, 1));
    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));
    JPanel dialogEastPanel = new JPanel();
    dialogEastPanel.setLayout(new BorderLayout());
    dialogEastPanel.add(buttonsPanel, BorderLayout.NORTH);
    dialog.getContentPane().add(this, BorderLayout.CENTER);
    dialog.getContentPane().add(dialogEastPanel, BorderLayout.EAST);
    dialog.pack();
    dialog.setLocationRelativeTo(frame);
    return dialog;
}
Also used : JPanel(javax.swing.JPanel) Frame(java.awt.Frame) Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) GridLayout(java.awt.GridLayout) BorderLayout(java.awt.BorderLayout) ActionMap(javax.swing.ActionMap) JButton(javax.swing.JButton) InputMap(javax.swing.InputMap) JDialog(javax.swing.JDialog)

Aggregations

JDialog (javax.swing.JDialog)181 JButton (javax.swing.JButton)70 JPanel (javax.swing.JPanel)61 ActionEvent (java.awt.event.ActionEvent)51 ActionListener (java.awt.event.ActionListener)39 JLabel (javax.swing.JLabel)39 JOptionPane (javax.swing.JOptionPane)34 BorderLayout (java.awt.BorderLayout)30 Dimension (java.awt.Dimension)27 JScrollPane (javax.swing.JScrollPane)27 JFrame (javax.swing.JFrame)23 BoxLayout (javax.swing.BoxLayout)21 FlowLayout (java.awt.FlowLayout)19 JCheckBox (javax.swing.JCheckBox)15 AbstractAction (javax.swing.AbstractAction)14 WindowEvent (java.awt.event.WindowEvent)13 JComponent (javax.swing.JComponent)12 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)11 WindowAdapter (java.awt.event.WindowAdapter)11 IOException (java.io.IOException)10