Search in sources :

Example 66 with JDialog

use of javax.swing.JDialog in project JMRI by JMRI.

the class WarrantTableAction method showPathPortalErrors.

public static boolean showPathPortalErrors() {
    if (!_hasErrors) {
        return false;
    }
    if (_textArea == null) {
        log.error("_textArea is null!.");
        return true;
    }
    JScrollPane scrollPane = new JScrollPane(_textArea);
    _errorDialog = new JDialog();
    _errorDialog.setTitle(Bundle.getMessage("ErrorDialogTitle"));
    JButton ok = new JButton(Bundle.getMessage("ButtonOK"));
    class myListener extends java.awt.event.WindowAdapter implements ActionListener {

        /*  java.awt.Window _w;
             myListener(java.awt.Window w) {
                 _w = w;
             }  */
        @Override
        public void actionPerformed(ActionEvent e) {
            _hasErrors = false;
            _textArea = null;
            _errorDialog.dispose();
        }

        @Override
        public void windowClosing(java.awt.event.WindowEvent e) {
            _hasErrors = false;
            _textArea = null;
            _errorDialog.dispose();
        }
    }
    ok.addActionListener(new myListener());
    ok.setMaximumSize(ok.getPreferredSize());
    java.awt.Container contentPane = _errorDialog.getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
    contentPane.add(scrollPane, BorderLayout.CENTER);
    contentPane.add(Box.createVerticalStrut(5));
    contentPane.add(Box.createVerticalGlue());
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
    panel.add(ok);
    contentPane.add(panel, BorderLayout.SOUTH);
    _errorDialog.addWindowListener(new myListener());
    _errorDialog.pack();
    _errorDialog.setVisible(true);
    return true;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JDialog(javax.swing.JDialog)

Example 67 with JDialog

use of javax.swing.JDialog in project JMRI by JMRI.

the class EntryExitPairs method stackNXRoute.

/**
     * If a route is requested but is currently blocked, ask user
     * if it should be added to stackList.
     *
     * @param dp DestinationPoints object
     * @param reverse true for a reversed running direction, mostly false
     */
public synchronized void stackNXRoute(DestinationPoints dp, boolean reverse) {
    if (isRouteStacked(dp, reverse)) {
        return;
    }
    stackList.add(new StackDetails(dp, reverse));
    checkTimer.start();
    if (stackPanel == null) {
        stackPanel = new StackNXPanel();
    }
    if (stackDialog == null) {
        stackDialog = new JDialog();
        stackDialog.setTitle(Bundle.getMessage("WindowTitleStackRoutes"));
        stackDialog.add(stackPanel);
    }
    stackPanel.updateGUI();
    stackDialog.pack();
    stackDialog.setModal(false);
    stackDialog.setVisible(true);
}
Also used : StackNXPanel(jmri.jmrit.signalling.entryexit.StackNXPanel) JDialog(javax.swing.JDialog)

Example 68 with JDialog

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

the class Listener method testHidenChildDispose.

/**
     * Test if a dialog that has never been shown fire
     * the WINDOW_CLOSED event on parent dispose().
     * @throws Exception
     */
public static void testHidenChildDispose() throws Exception {
    JFrame f = new JFrame();
    JDialog dlg = new JDialog(f);
    Listener l = new Listener();
    dlg.addWindowListener(l);
    f.dispose();
    waitEvents();
    assertEquals(0, l.getCount());
}
Also used : JFrame(javax.swing.JFrame) JDialog(javax.swing.JDialog)

Example 69 with JDialog

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

the class Listener method testVisibleChildParentDispose.

/**
     * Test if a dialog fire the WINDOW_CLOSED event
     * on parent dispose().
     * @throws Exception
     */
public static void testVisibleChildParentDispose() throws Exception {
    JFrame f = new JFrame();
    JDialog dlg = new JDialog(f);
    Listener l = new Listener();
    dlg.addWindowListener(l);
    dlg.setVisible(true);
    f.dispose();
    waitEvents();
    assertEquals(1, l.getCount());
}
Also used : JFrame(javax.swing.JFrame) JDialog(javax.swing.JDialog)

Example 70 with JDialog

use of javax.swing.JDialog in project n2a by frothga.

the class Lay method WLtg.

public static JPanel WLtg(Container target, Object... args) {
    HintList hints = new HintList();
    List<Component> cmpsChosen = new ArrayList<Component>();
    WrapLayout fl = new WrapLayout(FlowLayout.CENTER, 5, 5);
    for (Object arg : args) {
        if (arg instanceof String) {
            String str = (String) arg;
            // String axis override
            if (flAlign.get(str.toUpperCase()) != null) {
                fl.setAlignment(flAlign.get(str.toUpperCase()));
            // Add any hints
            } else {
                hints.addHints(parseHints(str));
            }
        // Integer axis override
        } else if (arg instanceof Integer) {
            fl.setAlignment((Integer) arg);
        // Save components
        } else if (arg instanceof Component) {
            cmpsChosen.add((Component) arg);
        } else if (arg instanceof ImageIcon) {
            if (target instanceof JFrame) {
                JFrame frame = (JFrame) target;
                frame.setIconImage(((ImageIcon) arg).getImage());
            } else if (target instanceof JDialog) {
                JDialog dlg = (JDialog) target;
                dlg.setIconImage(((ImageIcon) arg).getImage());
            }
        }
    // Else ignore
    }
    // Set layout on container, add components, and set hints on container.
    Container cont = chooseContainer(target, hints);
    cont.setLayout(fl);
    for (Component c : cmpsChosen) {
        cont.add(c);
    }
    setHints(cont, hints);
    return (target == null) ? (JPanel) cont : null;
}
Also used : ImageIcon(javax.swing.ImageIcon) Container(java.awt.Container) RootPaneContainer(javax.swing.RootPaneContainer) JFrame(javax.swing.JFrame) ArrayList(java.util.ArrayList) Component(java.awt.Component) JComponent(javax.swing.JComponent) JTextComponent(javax.swing.text.JTextComponent) 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