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

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

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

Window.setFocusable介绍

[英]Sets whether this Window can become the focused Window if it meets the other requirements outlined in isFocusableWindow. If this Window's focusable Window state is set to false, then isFocusableWindow will return false. If this Window's focusable Window state is set to true, then isFocusableWindow may return true or false depending upon the other requirements which must be met in order for a Window to be focusable.

Setting a Window's focusability state to false is the standard mechanism for an application to identify to the AWT a Window which will be used as a floating palette or toolbar, and thus should be a non-focusable Window.
[中]设置如果此窗口满足isFocusableWindow中概述的其他要求,是否可以成为聚焦窗口。如果此窗口的可聚焦窗口状态设置为false,则isFocusableWindow将返回false。如果此窗口的可聚焦窗口状态设置为true,则isFocusableWindow可能返回truefalse,具体取决于窗口可聚焦必须满足的其他要求。
将窗口的可聚焦状态设置为false是应用程序向AWT标识窗口的标准机制,该窗口将用作浮动调色板或工具栏,因此应该是不可聚焦的窗口。

代码示例

代码示例来源:origin: org.gephi/directory-chooser

private void setCursor(JComponent comp, int type) {
  Window window = SwingUtilities.getWindowAncestor(comp);
  if (window != null) {
    Cursor cursor = Cursor.getPredefinedCursor(type);
    window.setCursor(cursor);
    window.setFocusable(true);
  }
  
  JRootPane pane = fileChooser.getRootPane();
  if( null == blocker )
    blocker = new InputBlocker();
  
  if(type == Cursor.WAIT_CURSOR) {
    blocker.block(pane);
  } else if (type == Cursor.DEFAULT_CURSOR){
    blocker.unBlock(pane);
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-swingapp

win.setFocusable(true);
win.add(tooltip);
win.pack();

相关文章

微信公众号

最新文章

更多

Window类方法