Search in sources :

Example 66 with WindowEvent

use of java.awt.event.WindowEvent in project JMRI by JMRI.

the class EditNodeFrame method cancelButtonActionPerformed.

/**
     * Method to handle cancel button
     */
@Override
public void cancelButtonActionPerformed() {
    // Reset 
    curNode = null;
    // Switch buttons
    editButton.setVisible(true);
    cancelButton.setVisible(false);
    this.dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
}
Also used : WindowEvent(java.awt.event.WindowEvent)

Example 67 with WindowEvent

use of java.awt.event.WindowEvent in project jdk8u_jdk by JetBrains.

the class JOptionPane method initDialog.

private void initDialog(final JDialog dialog, int style, Component parentComponent) {
    dialog.setComponentOrientation(this.getComponentOrientation());
    Container contentPane = dialog.getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(this, BorderLayout.CENTER);
    dialog.setResizable(false);
    if (JDialog.isDefaultLookAndFeelDecorated()) {
        boolean supportsWindowDecorations = UIManager.getLookAndFeel().getSupportsWindowDecorations();
        if (supportsWindowDecorations) {
            dialog.setUndecorated(true);
            getRootPane().setWindowDecorationStyle(style);
        }
    }
    dialog.pack();
    dialog.setLocationRelativeTo(parentComponent);
    final PropertyChangeListener listener = new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            // (newValue = null in that case).  Otherwise, close the dialog.
            if (dialog.isVisible() && event.getSource() == JOptionPane.this && (event.getPropertyName().equals(VALUE_PROPERTY)) && event.getNewValue() != null && event.getNewValue() != JOptionPane.UNINITIALIZED_VALUE) {
                dialog.setVisible(false);
            }
        }
    };
    WindowAdapter adapter = new WindowAdapter() {

        private boolean gotFocus = false;

        public void windowClosing(WindowEvent we) {
            setValue(null);
        }

        public void windowClosed(WindowEvent e) {
            removePropertyChangeListener(listener);
            dialog.getContentPane().removeAll();
        }

        public void windowGainedFocus(WindowEvent we) {
            // Once window gets focus, set initial focus
            if (!gotFocus) {
                selectInitialValue();
                gotFocus = true;
            }
        }
    };
    dialog.addWindowListener(adapter);
    dialog.addWindowFocusListener(adapter);
    dialog.addComponentListener(new ComponentAdapter() {

        public void componentShown(ComponentEvent ce) {
            // reset value to ensure closing works properly
            setValue(JOptionPane.UNINITIALIZED_VALUE);
        }
    });
    addPropertyChangeListener(listener);
}
Also used : Container(java.awt.Container) PropertyChangeEvent(java.beans.PropertyChangeEvent) BorderLayout(java.awt.BorderLayout) PropertyChangeListener(java.beans.PropertyChangeListener) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 68 with WindowEvent

use of java.awt.event.WindowEvent in project jdk8u_jdk by JetBrains.

the class KeyboardFocusManager method retargetFocusEvent.

static AWTEvent retargetFocusEvent(AWTEvent event) {
    if (clearingCurrentLightweightRequests) {
        return event;
    }
    KeyboardFocusManager manager = getCurrentKeyboardFocusManager();
    if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
        if (event instanceof FocusEvent || event instanceof WindowEvent) {
            focusLog.finer(">>> {0}", String.valueOf(event));
        }
        if (focusLog.isLoggable(PlatformLogger.Level.FINER) && event instanceof KeyEvent) {
            focusLog.finer("    focus owner is {0}", String.valueOf(manager.getGlobalFocusOwner()));
            focusLog.finer(">>> {0}", String.valueOf(event));
        }
    }
    synchronized (heavyweightRequests) {
        /*
             * This code handles FOCUS_LOST event which is generated by
             * DefaultKeyboardFocusManager for FOCUS_GAINED.
             *
             * This code based on knowledge of DefaultKeyboardFocusManager's
             * implementation and might be not applicable for another
             * KeyboardFocusManager.
             *
             * Fix for 4472032
             */
        if (newFocusOwner != null && event.getID() == FocusEvent.FOCUS_LOST) {
            FocusEvent fe = (FocusEvent) event;
            if (manager.getGlobalFocusOwner() == fe.getComponent() && fe.getOppositeComponent() == newFocusOwner) {
                newFocusOwner = null;
                return event;
            }
        }
    }
    processCurrentLightweightRequests();
    switch(event.getID()) {
        case FocusEvent.FOCUS_GAINED:
            {
                event = retargetFocusGained((FocusEvent) event);
                break;
            }
        case FocusEvent.FOCUS_LOST:
            {
                event = retargetFocusLost((FocusEvent) event);
                break;
            }
        default:
    }
    return event;
}
Also used : KeyEvent(java.awt.event.KeyEvent) WindowEvent(java.awt.event.WindowEvent) CausedFocusEvent(sun.awt.CausedFocusEvent) FocusEvent(java.awt.event.FocusEvent)

Example 69 with WindowEvent

use of java.awt.event.WindowEvent in project JMRI by JMRI.

the class PaneProgAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (log.isDebugEnabled()) {
        log.debug("Pane programmer requested");
    }
    // create the initial frame that steers
    final JmriJFrame f = new JmriJFrame(SymbolicProgBundle.getMessage("FrameServiceProgrammerSetup"));
    f.getContentPane().setLayout(new BoxLayout(f.getContentPane(), BoxLayout.Y_AXIS));
    // ensure status line is cleared on close so it is normal if re-opened
    f.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent we) {
            statusLabel.setText(SymbolicProgBundle.getMessage("StateIdle"));
            f.windowClosing(we);
        }
    });
    // add the Roster menu
    JMenuBar menuBar = new JMenuBar();
    // menuBar.setBorder(new BevelBorder(BevelBorder.RAISED));
    JMenu j = new JMenu(SymbolicProgBundle.getMessage("MenuFile"));
    j.add(new jmri.jmrit.decoderdefn.PrintDecoderListAction(SymbolicProgBundle.getMessage("MenuPrintDecoderDefinitions"), f, false));
    j.add(new jmri.jmrit.decoderdefn.PrintDecoderListAction(SymbolicProgBundle.getMessage("MenuPrintPreviewDecoderDefinitions"), f, true));
    menuBar.add(j);
    menuBar.add(new jmri.jmrit.roster.swing.RosterMenu(SymbolicProgBundle.getMessage("MenuRoster"), jmri.jmrit.roster.swing.RosterMenu.MAINMENU, f));
    f.setJMenuBar(menuBar);
    // new Loco on programming track
    JPanel pane1 = new CombinedLocoSelTreePane(statusLabel, modePane) {

        @Override
        protected void startProgrammer(DecoderFile decoderFile, RosterEntry re, String filename) {
            String title = java.text.MessageFormat.format(SymbolicProgBundle.getMessage("FrameServiceProgrammerTitle"), new Object[] { "new decoder" });
            if (re != null) {
                title = java.text.MessageFormat.format(SymbolicProgBundle.getMessage("FrameServiceProgrammerTitle"), new Object[] { re.getId() });
            }
            JFrame p = new PaneServiceProgFrame(decoderFile, re, title, "programmers" + File.separator + filename + ".xml", modePane.getProgrammer());
            p.pack();
            p.setVisible(true);
        // f.setVisible(false);
        // f.dispose();
        }
    };
    // load primary frame
    JPanel tempPane = new JPanel();
    tempPane.add(modePane);
    f.getContentPane().add(tempPane);
    f.getContentPane().add(new JSeparator(javax.swing.SwingConstants.HORIZONTAL));
    pane1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
    f.getContentPane().add(pane1);
    f.getContentPane().add(new JSeparator(javax.swing.SwingConstants.HORIZONTAL));
    statusLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
    f.getContentPane().add(statusLabel);
    f.pack();
    if (log.isDebugEnabled()) {
        log.debug("Tab-Programmer setup created");
    }
    f.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) DecoderFile(jmri.jmrit.decoderdefn.DecoderFile) BoxLayout(javax.swing.BoxLayout) WindowAdapter(java.awt.event.WindowAdapter) JSeparator(javax.swing.JSeparator) JmriJFrame(jmri.util.JmriJFrame) JmriJFrame(jmri.util.JmriJFrame) JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent) RosterEntry(jmri.jmrit.roster.RosterEntry) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu) CombinedLocoSelTreePane(jmri.jmrit.symbolicprog.CombinedLocoSelTreePane)

Example 70 with WindowEvent

use of java.awt.event.WindowEvent in project processdash by dtuma.

the class TimeLogEditor method constructUserInterface.

/*
     * methods for constructing the user interface
     */
private void constructUserInterface() {
    loadCustomDimensions();
    frame = new JFrame(getResource("Time_Log_Editor_Window_Title"));
    DashboardIconFactory.setWindowIcon(frame);
    frame.setSize(new Dimension(frameWidth, frameHeight));
    frame.addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent e) {
            confirmClose(true);
        }
    });
    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    PCSH.enableHelpKey(frame, "UsingTimeLogEditor");
    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, constructTreePanel(), constructEditPanel());
    splitPane.setDividerLocation(dividerLocation);
    // Setup drag-and-drop support on Java 6 and above
    new FallbackObjectFactory<TimeLogEditorDragDropSetup>(TimeLogEditorDragDropSetup.class).add(//
    "TimeLogEditorDragDropSetupJava6").get(true).setupEditorForDragDrop(this);
    Container panel = frame.getContentPane();
    panel.setLayout(new BorderLayout());
    panel.add(BorderLayout.NORTH, constructFilterPanel());
    panel.add(BorderLayout.CENTER, splitPane);
    panel.add(BorderLayout.SOUTH, constructControlPanel());
    createRecalcTimer();
}
Also used : Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension) JSplitPane(javax.swing.JSplitPane)

Aggregations

WindowEvent (java.awt.event.WindowEvent)201 WindowAdapter (java.awt.event.WindowAdapter)140 JPanel (javax.swing.JPanel)44 JButton (javax.swing.JButton)40 JFrame (javax.swing.JFrame)40 BorderLayout (java.awt.BorderLayout)36 ActionEvent (java.awt.event.ActionEvent)34 Dimension (java.awt.Dimension)32 JLabel (javax.swing.JLabel)30 JScrollPane (javax.swing.JScrollPane)26 ActionListener (java.awt.event.ActionListener)25 GridBagConstraints (java.awt.GridBagConstraints)19 GridBagLayout (java.awt.GridBagLayout)19 FlowLayout (java.awt.FlowLayout)18 Frame (java.awt.Frame)15 Insets (java.awt.Insets)15 JDialog (javax.swing.JDialog)13 JTextArea (javax.swing.JTextArea)13 Container (java.awt.Container)12 WindowListener (java.awt.event.WindowListener)10