Package java.awt.event

Examples of java.awt.event.WindowEvent


      aboutDialog.setVisible(true);
    } else if (source == helpMenuItem) {
      JOptionPane.showMessageDialog(CpmFrame.this, CpmPanel.HELP_MESSAGE,
              "Collection Processing Engine Configurator Help", JOptionPane.PLAIN_MESSAGE);
    } else if (source == exitMenuItem) {
      this.processWindowEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
    }
  }
View Full Code Here


     * Class under test for void processWindowEvent(WindowEvent)
     */
    public void testProcessWindowEvent() {
        TestFrame frame = new TestFrame();
        frame.setVisible(true);
        WindowEvent e = new WindowEvent(frame, WindowEvent.WINDOW_CLOSING);
        // test DO_NOTHING_ON_CLOSE
        frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
        frame.disposeCalled = false;
        frame.processWindowEvent(e);
        assertFalse("didn't call dispose()", frame.disposeCalled);
View Full Code Here

  /**
   * Simulates closing the window down via pressing the close window button
   * on your operating system. Will shut down the program entirely.
   */
  public void shutdown() {
    processWindowEvent( new WindowEvent( this, WindowEvent.WINDOW_CLOSING ) );
  }
View Full Code Here

    this.file.add(close);
    this.getJMenuBar().add(file);
  }
 
  protected void close(){
    WindowEvent we = new WindowEvent(this,WindowEvent.WINDOW_CLOSING, null, 0, 0);
    getWindowListeners()[0].windowClosing(we);
  }
View Full Code Here

        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
        menuItem.addActionListener(new AbstractAction() {
      private static final long serialVersionUID = 1L;
            public void actionPerformed(ActionEvent event) {
              JFrame frame = XBayaMenuItem.this.engine.getGUI().getFrame();
        frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
            }
        });
        return menuItem;
    }
View Full Code Here

  // We want to ignore consecutive event indicating window disposal; it needs to be an intervening SHOWN/OPEN before
  // we're interested again.
  boolean isDuplicateDispose(AWTEvent event) {
    if (!(event instanceof WindowEvent)) return false;
    WindowEvent windowEvent = (WindowEvent) event;
    int eventId = windowEvent.getID();
    if (eventId == WINDOW_CLOSING) return false;
    if (eventId == WINDOW_CLOSED) {
      Window w = windowEvent.getWindow();
      if (disposedWindows.containsKey(w)) return true;
      disposedWindows.put(w, true);
      // execute(addComponentListenerTask(w, new DisposalMonitor(disposedWindows)));
      w.addComponentListener(new DisposalMonitor(disposedWindows));
      return false;
    }
    disposedWindows.remove(windowEvent.getWindow());
    return false;
  }
View Full Code Here

  }

  /** {@inheritDoc} */
  @RunsInEDT
  public void close(Window w) {
    WindowEvent event = new WindowEvent(w, WINDOW_CLOSING);
    // If the window contains an applet, send the event on the applet's queue instead to ensure a shutdown from the
    // applet's context (assists AppletViewer cleanup).
    Component applet = findAppletDescendent(w);
    EventQueue eventQueue = windowMonitor.eventQueueFor(applet != null ? applet : w);
    eventQueue.postEvent(event);
View Full Code Here

    /**
     * Closes this {@link Window}, warning its listeners
     */
    protected final void close() {
        WindowEvent event = new WindowEvent(this, WindowEvent.WINDOW_CLOSING);
        for (WindowListener listener : getWindowListeners()) {
            listener.windowClosing(event);
        }
        setVisible(false);
        event = new WindowEvent(this, WindowEvent.WINDOW_CLOSED);
        for (WindowListener listener : getWindowListeners()) {
            listener.windowClosed(event);
        }
        event = null;
    }
View Full Code Here

            @Override
            public void actionPerformed(final ActionEvent e) {
                // tell the frame to close itself
                JFrame topFrame = DataStorageApplication.this;
                WindowEvent windowClosing = new WindowEvent(topFrame, WindowEvent.WINDOW_CLOSING);
                topFrame.dispatchEvent(windowClosing);
            }
        });

        JMenuItem aboutMenuItem = new JMenuItem(new AbstractAction(MESSAGES.getString("Action.About")) {
View Full Code Here

            @Override
            public void actionPerformed(final ActionEvent e) {
                // tell the frame to close itself
                JFrame topFrame = DataStorageApplication.this;
                WindowEvent windowClosing = new WindowEvent(topFrame, WindowEvent.WINDOW_CLOSING);
                topFrame.dispatchEvent(windowClosing);
            }
        });

        JMenuItem aboutMenuItem = new JMenuItem(new AbstractAction(MESSAGES.getString("Action.About")) {
View Full Code Here

TOP

Related Classes of java.awt.event.WindowEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.