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

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

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

Window.addWindowFocusListener介绍

[英]Adds the specified window focus listener to receive window events from this window. If l is null, no exception is thrown and no action is performed.
[中]添加指定的窗口焦点侦听器以从此窗口接收窗口事件。如果l为null,则不会引发异常,也不会执行任何操作。

代码示例

代码示例来源:origin: nodebox/nodebox

@Override
  public void run() {
    SwingUtilities.getWindowAncestor(ZoomableView.this).addWindowFocusListener(fh);
  }
});

代码示例来源:origin: bobbylight/RSyntaxTextArea

Listener() {
  addWindowFocusListener(this);
  // If anything happens to the "parent" window, hide this popup
  Window parent = (Window)getParent();
  parent.addWindowFocusListener(this);
  parent.addWindowListener(this);
  parent.addComponentListener(this);
}

代码示例来源:origin: bobbylight/RSyntaxTextArea

Listener() {
  addWindowFocusListener(this);
  list.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseClicked(MouseEvent e) {
      if (e.getClickCount()==2) {
        insertSelectedItem();
      }
    }
  });
  list.getInputMap().put(
      KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "onEnter");
  list.getActionMap().put("onEnter", new AbstractAction() {
    @Override
    public void actionPerformed(ActionEvent e) {
      insertSelectedItem();
    }
  });
  // If anything happens to the "parent" window, hide this popup
  Window parent = (Window)getParent();
  parent.addWindowFocusListener(this);
  parent.addWindowListener(this);
  parent.addComponentListener(this);
}

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

this.setLocationRelativeTo(owner);
this.setAlwaysOnTop(true);
this.addWindowFocusListener(new WindowFocusListener() {

代码示例来源:origin: org.scijava/scijava-ui-swing

/**
 * Makes the given component grab the keyboard focus whenever the window gains
 * the focus.
 */
private void setDefaultFocusComponent(final Window w, final Component c) {
  w.addWindowFocusListener(new WindowAdapter() {
    @Override
    public void windowGainedFocus(final WindowEvent e) {
      c.requestFocusInWindow();
    }
  });
}

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

public void addWindow(Window window) {
  window.addWindowFocusListener(focusHandler);
  windows.put(window, null);
}
public void removeWindow(Window window) {

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

public void addPalette(Window palette) {
  palette.addWindowFocusListener(focusHandler);
  palettes.add(palette);
}

代码示例来源:origin: freeplane/freeplane

public void windowGainedFocus(WindowEvent e) {
    frame.addWindowFocusListener(new WindowFocusListener() {
      public void windowLostFocus(WindowEvent e) {
      }
      
      public void windowGainedFocus(WindowEvent e) {
        d.setVisible(false);
        frame.removeWindowFocusListener(this);
      }
    });
    d.removeWindowFocusListener(this);
  }
});

代码示例来源:origin: freeplane/freeplane

public void trackWindowForComponent(Component c){
  final Window windowToTrack = SwingUtilities.getWindowAncestor(c);
  if(windowToTrack.equals(trackedWindow))
    return;
  if(trackedWindow != null)
    trackedWindow.removeWindowFocusListener(this);
  trackedWindow = windowToTrack;
  trackedWindow.addWindowFocusListener(this);
  mousePositionAfterFocusGained = null;
}

代码示例来源:origin: com.threerings/nenya

public void ancestorAdded (AncestorEvent e)
{
  gainedFocus();
  if (_window == null) {
    _window = SwingUtilities.getWindowAncestor(_target);
    _window.addWindowFocusListener(this);
  }
}

代码示例来源:origin: threerings/nenya

public void ancestorAdded (AncestorEvent e)
{
  gainedFocus();
  if (_window == null) {
    _window = SwingUtilities.getWindowAncestor(_target);
    _window.addWindowFocusListener(this);
  }
}

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

public void add(Window window, @Nullable View view) {
  window.addWindowFocusListener(focusHandler);
  windows.put(window, view);
}

代码示例来源:origin: com.fifesoft/autocomplete

public void addTo(Window w) {
  w.addComponentListener(this);
  w.addWindowFocusListener(this);
}

代码示例来源:origin: org.opentcs.thirdparty.dockingframes/docking-frames-core

public void add( Window window ){
  if( monitored.add( window ) ){
    window.addWindowFocusListener( listener );
    if( window.isActive() ){
      current = window;
      fireWindowChanged( window );
      history.add( current );
    }
    else{
      history.add( 0, window );
    }
  }
}

代码示例来源:origin: xyz.cofe/docking-frames-core

public void add( Window window ){
  if( monitored.add( window ) ){
    window.addWindowFocusListener( listener );
    if( window.isActive() ){
      current = window;
      fireWindowChanged( window );
      history.add( current );
    }
    else{
      history.add( 0, window );
    }
  }
}

代码示例来源:origin: freeplane/freeplane

private void restoreFocusToMainView() {
  final Window windowAncestor = SwingUtilities.getWindowAncestor(mainView);
  if(windowAncestor.isFocused())
    mainView.requestFocusInWindow();
  else
    windowAncestor.addWindowFocusListener(new WindowFocusListener() {
      @Override
      public void windowLostFocus(WindowEvent e) {
      }
      @Override
      public void windowGainedFocus(WindowEvent e) {
        mainView.requestFocusInWindow();
        windowAncestor.removeWindowFocusListener(this);
      }
    });
}

代码示例来源:origin: com.threerings/nenya

/**
 * Constructs a key dispatcher.
 */
public KeyDispatcher (Window window)
{
  // save things off
  _window = window;
  // listen to window events on our main window so that we can release
  // keys when the mouse leaves the window
  _window.addWindowFocusListener(this);
  // monitor key events from the central dispatch mechanism
  KeyboardFocusManager.getCurrentKeyboardFocusManager().
    addKeyEventDispatcher(this);
}

代码示例来源:origin: threerings/nenya

/**
 * Constructs a key dispatcher.
 */
public KeyDispatcher (Window window)
{
  // save things off
  _window = window;
  // listen to window events on our main window so that we can release
  // keys when the mouse leaves the window
  _window.addWindowFocusListener(this);
  // monitor key events from the central dispatch mechanism
  KeyboardFocusManager.getCurrentKeyboardFocusManager().
    addKeyEventDispatcher(this);
}

代码示例来源:origin: com.fifesoft/rsyntaxtextarea

Listener() {
  addWindowFocusListener(this);
  // If anything happens to the "parent" window, hide this popup
  Window parent = (Window)getParent();
  parent.addWindowFocusListener(this);
  parent.addWindowListener(this);
  parent.addComponentListener(this);
}

代码示例来源:origin: org.xworker/xworker_core

public static void createWindowFocusListeners(ActionContext actionContext){
  Thing self = (Thing) actionContext.get("self");
  Window parent = (Window) actionContext.get("parent");
  
  for(Thing child : self.getChilds()){
    WindowFocusListener l = (WindowFocusListener) child.doAction("create", actionContext);
    if(l != null){
      parent.addWindowFocusListener(l);
    }
  }
}

相关文章

Window类方法