java.awt.Window.dispatchEvent()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(443)

本文整理了Java中java.awt.Window.dispatchEvent()方法的一些代码示例,展示了Window.dispatchEvent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.dispatchEvent()方法的具体详情如下:
包路径:java.awt.Window
类名称:Window
方法名:dispatchEvent

Window.dispatchEvent介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

Window window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();

if (window != null)
{
  WindowEvent windowClosing = new WindowEvent(window, WindowEvent.WINDOW_CLOSING);
  window.dispatchEvent(windowClosing);
}

代码示例来源:origin: stackoverflow.com

public class CancelAction extends AbstractAction
{
  public CancelAction()
  {
    super("Cancel");
    putValue( Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_C) );
  }

  @Override
  public void actionPerformed(ActionEvent e)
  {
    Window window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();

    if (window != null)
    {
      WindowEvent windowClosing = new WindowEvent(window, WindowEvent.WINDOW_CLOSING);
      window.dispatchEvent(windowClosing);
    }
  }
}

代码示例来源:origin: org.java.net.substance/substance

public void actionPerformed(ActionEvent e) {
    Window window = SubstanceTitlePane.this.getWindow();
    if (window != null) {
      window.dispatchEvent(new WindowEvent(window,
          WindowEvent.WINDOW_CLOSING));
    }
  }
}

代码示例来源:origin: khuxtable/seaglass

/**
 * Close the window.
 */
private void doParentDefaultCloseAction() {
  ((Window) rootParent).dispatchEvent(new WindowEvent((Window) rootParent, WindowEvent.WINDOW_CLOSING));
}

代码示例来源:origin: net.sf.gluebooster.java.booster/gb-basic

/**
 * Dispatch a closing event to the window.
 */
public static void dispatchClosingEvent(Window window) {
  window.dispatchEvent(createClosingEvent(window));
}

代码示例来源:origin: org.bidib.jbidib.com.vldocking/vldocking

public void mousePressed(MouseEvent e) {
    // collapse the expanded panel and redispatch the event to the
    // underlying frame
    // for processing by the real component clicked by the user
    expandPanel.collapse();
    Window w = SwingUtilities
        .getWindowAncestor(DockingDesktop.this);
    if (w != null) {
      w.dispatchEvent(e);
    }
  }
});

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/napkinlaf

/** Closes the Window. */
private void close() {
  if (window != null) {
    window.dispatchEvent(new WindowEvent(window,
        WindowEvent.WINDOW_CLOSING));
  }
}

代码示例来源:origin: com.github.insubstantial/substance

@Override
  public void actionPerformed(ActionEvent e) {
    Window window = SubstanceTitlePane.this.getWindow();
    if (window != null) {
      window.dispatchEvent(new WindowEvent(window,
          WindowEvent.WINDOW_CLOSING));
    }
  }
}

代码示例来源:origin: org.databene/databene-commons

@Override
public void actionPerformed(ActionEvent e) {
  if (window == null)
    return;
  window.dispatchEvent(new WindowEvent(window, WindowEvent.WINDOW_CLOSING));
}

代码示例来源:origin: com.jtattoo/JTattoo

public void close() {
  if (window != null) {
    window.dispatchEvent(new WindowEvent(window, WindowEvent.WINDOW_CLOSING));
  }
}

代码示例来源:origin: omegat-org/omegat

/**
 * Send a {@link WindowEvent#WINDOW_CLOSING} event to the supplied window.
 * This mimics closing by clicking the window close button.
 */
public static void closeWindowByEvent(Window window) {
  window.dispatchEvent(new WindowEvent(window, WindowEvent.WINDOW_CLOSING));
}

代码示例来源:origin: stackoverflow.com

JButton closeButton = new JButton("Close");
closeButton.addActionListener(new ActionListener() {
  @Override
  public void actionPerformed(ActionEvent e) {
    Window window = SwingUtilities.windowForComponent((JButton)e.getSource());
    window.dispatchEvent(new WindowEvent(window, WindowEvent.WINDOW_CLOSING));
  }
});

...

JFrame frame = new JFrame("Frame");
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
frame.addWindowListener(new WindowAdapter() {

  @Override
  public void windowClosing(WindowEvent e) {
    // Call methodA() here.
    // If all went ok then dispose the window, otherwise log the 
    // errors/exceptions and notify the user that something went wrong.
    e.getWindow().dispose();
  }
});

代码示例来源:origin: com.itextpdf/itext-rups

@Override
public void dispose() {
  Window frame = getOwner();
  super.dispose();
  if (!pluginMode) {
    frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf

/**
 * Closes the Window.
 */
private void close()
{
  Window window = getWindow();
  if (window != null)
  {
    window.dispatchEvent(
      new WindowEvent(window, WindowEvent.WINDOW_CLOSING));
  }
}

代码示例来源:origin: net.sf.squirrel-sql/squirrel-sql

public void widgetActivated(WidgetEvent evt)
  {
    Window window = SwingUtilities.windowForComponent(ObjectTreeInternalFrame.this.getObjectTreePanel());
    Component focusOwner = (window != null) ? window.getFocusOwner() : null;
    if (focusOwner != null)
    {
      FocusEvent lost = new FocusEvent(focusOwner, FocusEvent.FOCUS_LOST);
      FocusEvent gained = new FocusEvent(focusOwner, FocusEvent.FOCUS_GAINED);
      window.dispatchEvent(lost);
      window.dispatchEvent(gained);
      window.dispatchEvent(lost);
      focusOwner.requestFocus();
    }
  }
});

代码示例来源:origin: realXuJiang/bigtable-sql

public void widgetActivated(WidgetEvent evt)
  {
    Window window = SwingUtilities.windowForComponent(ObjectTreeInternalFrame.this.getObjectTreePanel());
    Component focusOwner = (window != null) ? window.getFocusOwner() : null;
    if (focusOwner != null)
    {
      FocusEvent lost = new FocusEvent(focusOwner, FocusEvent.FOCUS_LOST);
      FocusEvent gained = new FocusEvent(focusOwner, FocusEvent.FOCUS_GAINED);
      window.dispatchEvent(lost);
      window.dispatchEvent(gained);
      window.dispatchEvent(lost);
      focusOwner.requestFocus();
    }
  }
});

代码示例来源:origin: Waikato/weka-trunk

/**
 * closes the window, i.e., if the parent is not null and implements the
 * WindowListener interface it calls the windowClosing method
 */
public void close() {
 if (getParentInternalFrame() != null) {
  getParentInternalFrame().doDefaultCloseAction();
 } else if (getParentFrame() != null) {
  ((Window) getParentFrame()).dispatchEvent(new WindowEvent(
   getParentFrame(), WindowEvent.WINDOW_CLOSING));
 }
}

代码示例来源:origin: net.sf.meka/meka

/**
 * closes the window, i.e., if the parent is not null and implements the
 * WindowListener interface it calls the windowClosing method
 */
public void close() {
  if (getParentInternalFrame() != null) {
    getParentInternalFrame().doDefaultCloseAction();
  } else if (getParentFrame() != null) {
    ((Window) getParentFrame()).dispatchEvent(new WindowEvent(
      getParentFrame(), WindowEvent.WINDOW_CLOSING));
  }
}

代码示例来源:origin: Waikato/meka

/**
 * closes the window, i.e., if the parent is not null and implements the
 * WindowListener interface it calls the windowClosing method
 */
public void close() {
  if (getParentInternalFrame() != null) {
    getParentInternalFrame().doDefaultCloseAction();
  } else if (getParentFrame() != null) {
    ((Window) getParentFrame()).dispatchEvent(new WindowEvent(
      getParentFrame(), WindowEvent.WINDOW_CLOSING));
  }
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * closes the window, i.e., if the parent is not null and implements the
 * WindowListener interface it calls the windowClosing method
 */
public void close() {
 if (getParentInternalFrame() != null) {
  getParentInternalFrame().doDefaultCloseAction();
 } else if (getParentFrame() != null) {
  ((Window) getParentFrame()).dispatchEvent(new WindowEvent(
   getParentFrame(), WindowEvent.WINDOW_CLOSING));
 }
}

相关文章

Window类方法