Java 8 WindowEvent - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 WindowEvent class.

This code example shows how to use the following methods:
    assertThat(AWTEvents.wasWindowOpened(event)).isTrue();
  } 
 
  @Test
  public void should_return_false_if_Window_not_opened() { 
    AWTEvent event = new WindowEvent(source, WINDOW_CLOSING);
    assertThat(AWTEvents.wasWindowOpened(event)).isFalse();
  } 
} 
5
CodeRank
This code example shows how to use the following methods:
    assertThat(AWTEvents.wasWindowClosed(event)).isTrue();
  } 
 
  @Test
  public void should_return_false_if_Window_not_closed() { 
    AWTEvent event = new WindowEvent(source, WINDOW_CLOSING);
    assertThat(AWTEvents.wasWindowClosed(event)).isFalse();
  } 
} 
5
CodeRank
This code example shows how to use the following methods:getID, getWindow
  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());

5
CodeRank
This code example shows how to use the following methods:getID
     * 
     * @see #setDefaultCloseOperation 
     */ 
    protected void processWindowEvent(WindowEvent e)
    { 
        super.processWindowEvent(e);
 
        if (e.getID() == WindowEvent.WINDOW_OPENED) pack();
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getID
     * 
     * @param e event. 
     */ 
    protected void processWindowEvent(WindowEvent e)
    { 
        super.processWindowEvent(e);
 
        if (e.getID() == WindowEvent.WINDOW_OPENED) pack();
    } 
 
    /** 
     * Returns username from the field. 
     * 
     * @return username. 
     */ 
    public String getUsername()
    { 
        return tfUsername.getText();
    } 
 
5
CodeRank
This code example shows how to use the following methods:getID
     * 
     * @see #setDefaultCloseOperation 
     */ 
    protected void processWindowEvent(WindowEvent e)
    { 
        super.processWindowEvent(e);
 
        if (e.getID() == WindowEvent.WINDOW_OPENED) pack();
    } 
 
    /** 
     * Returns the list of feeds to add. 
     * 
     * @return feeds to add. 
     */ 
    public List getAddFeeds()
    { 
        return FeedCheckBox.getSelected(lstAddFeeds.getModel());
    } 
 
5
CodeRank
This code example shows how to use the following methods:
            } 
        }); 
    } 
 
    public static void closeWindow(Window w) {
        w.getToolkit().getSystemEventQueue().postEvent(new WindowEvent(w, WindowEvent.WINDOW_CLOSING));
    } 
 
    public static Frame getFrame(Component c) {
        Component ret = c;
        while (ret != null && !(ret instanceof Frame)) {
            ret = ret.getParent();
        } 
        return (Frame) ret;
    } 
 
    public static JFrame getJFrame(Component c) {
        Component ret = c;
        while (ret != null && !(ret instanceof JFrame)) {
            ret = ret.getParent();
5
CodeRank
This code example shows how to use the following methods:getWindow
     * Listens for the main window closing, and shuts down the application. 
     * 
     * @param event  information about the window event. 
     */ 
    public void windowClosing(final WindowEvent event) {
        if (event.getWindow() == this) {
            dispose();
            System.exit(0);
        } 
    } 
 
    /** 
     * Required for WindowListener interface, but not used by this class. 
     * 
     * @param event  information about the window event. 
     */ 
    public void windowClosed(final WindowEvent event) {
        // ignore 
    } 
 
5
CodeRank
This code example shows how to use the following methods:getWindow
   * @param y 		initial y coord for the dialog 
   */ 
  protected void initialize(PropertyEditor pe, int x, int y) {
    addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
	e.getWindow().dispose();
      } 
    }); 
    getContentPane().setLayout(new BorderLayout());
 
    m_Editor = pe;
    m_EditorComponent = pe.getCustomEditor();
    getContentPane().add(m_EditorComponent, BorderLayout.CENTER);
 
    pack();
     
    int screenWidth = getGraphicsConfiguration().getBounds().width;
    int screenHeight = getGraphicsConfiguration().getBounds().height;
 
    // adjust height to a maximum of 95% of screen height 
5
CodeRank
This code example shows how to use the following methods:getWindow
        if (!headless.equalsIgnoreCase("true") && TestData.isInteractiveTest()) {
            try { 
                JFrame frame = new JFrame(getName());
                frame.addWindowListener(new WindowAdapter() {
                    public void windowClosing(WindowEvent e) {
                        e.getWindow().dispose();
                    } 
                }); 
                frame.setContentPane(panel);
                frame.setSize(new Dimension(500,500));
                frame.setVisible(true);
 
                Thread.sleep(5000);
                frame.dispose();
            } catch (HeadlessException exception) {
                // The test is running on a machine without X11 display. Ignore. 
                return; 
            } 
        } 
    } 
5
CodeRank
See Code Examples for Java 8 WindowEvent Methods: