本文整理了Java中java.awt.Window.isActive()
方法的一些代码示例,展示了Window.isActive()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.isActive()
方法的具体详情如下:
包路径:java.awt.Window
类名称:Window
方法名:isActive
[英]Returns whether this Window is active. Only a Frame may be active. The native windowing system may denote the active Window or its children with special decorations, such as a highlighted title bar. The active Window is always either the focused Window, or the first Frame that is an owner of the focused Window.
[中]返回此窗口是否处于活动状态。只有一个帧可能处于活动状态。本机窗口系统可能会使用特殊的装饰(例如高亮显示的标题栏)来表示活动窗口或其子窗口。活动窗口始终是聚焦窗口,或者是作为聚焦窗口所有者的第一帧。
代码示例来源:origin: de.sciss/scisslib
public boolean isActive()
{
if( w != null ) {
return w.isActive();
} else {
return false;
}
}
代码示例来源:origin: stackoverflow.com
// Workaround for issue
// (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6770457)
PopupFactory.setSharedInstance(new PopupFactory() {
@Override
public Popup getPopup(Component owner, Component contents, int x, int y) {
Window win = SwingUtilities.getWindowAncestor(owner);
if (win.isActive()) {
return super.getPopup(owner, contents, x, y);
}
return super.getPopup(JOptionPane.getRootFrame(), contents, x, y);
}
});
// end fix
代码示例来源:origin: de.richtercloud/flexdock-core
public boolean isActive() {
Component root = getRootContainer();
if (root instanceof JFrame) {
return ((Window) root).isActive();
} else if (root instanceof JWindow) {
return ((Window) root).isActive();
} else if (root instanceof JDialog) {
return ((Window) root).isActive();
}
return false;
}
代码示例来源:origin: chatty/chatty
public Window getActiveWindow() {
for (Window frame : Window.getWindows()) {
if (frame.isActive()) {
return frame;
}
}
return this;
}
代码示例来源:origin: chatty/chatty
public boolean isAppActive() {
for (Window frame : Window.getWindows()) {
if (frame.isActive()) {
return true;
}
}
return false;
}
代码示例来源:origin: stackoverflow.com
for (Window frame : Window.getWindows())
{
if (frame.isActive())
{
frame.setVisible(false);
}
}
代码示例来源:origin: com.synaptix/SynaptixSwing
@Deprecated
public Window peek() {
Window[] ws = Window.getWindows();
for (Window w : ws) {
if (w.isActive()) {
return w;
}
}
throw new RuntimeException();
// return displayStack.peek().getWindow();
}
代码示例来源:origin: net.sf.tinylaf/tinylaf
public boolean isSelected() {
Window window = getWindow();
return (window == null) ? true : window.isActive();
}
代码示例来源:origin: com.synaptix/SynaptixSwing
@Deprecated
public boolean isFrame() {
Window[] ws = Window.getWindows();
for (Window w : ws) {
if (w.isActive()) {
return w instanceof JFrame;
}
}
throw new RuntimeException();
// return displayStack.peek().getWindow() instanceof JFrame;
}
代码示例来源:origin: com.synaptix/SynaptixSwing
@Deprecated
public boolean isDialog() {
Window[] ws = Window.getWindows();
for (Window w : ws) {
if (w.isActive()) {
return w instanceof JDialog;
}
}
throw new RuntimeException();
// return displayStack.peek().getWindow() instanceof JDialog;
}
代码示例来源:origin: xyz.cofe/docking-frames-core
/**
* Tells whether the focus of this component is currently lost, but
* will be retrieved as soon as the underlying frame gets activated.
* @return <code>true</code> if the focus is only temporarily lost
*/
public boolean isFocusTemporarilyLost(){
Window window = SwingUtilities.getWindowAncestor( getComponent() );
boolean focusTemporarilyLost = false;
if( window != null ){
focusTemporarilyLost = !window.isActive();
}
return focusTemporarilyLost;
}
代码示例来源:origin: org.opentcs.thirdparty.dockingframes/docking-frames-core
/**
* Tells whether the focus of this component is currently lost, but
* will be retrieved as soon as the underlying frame gets activated.
* @return <code>true</code> if the focus is only temporarily lost
*/
public boolean isFocusTemporarilyLost(){
Window window = SwingUtilities.getWindowAncestor( getComponent() );
boolean focusTemporarilyLost = false;
if( window != null ){
focusTemporarilyLost = !window.isActive();
}
return focusTemporarilyLost;
}
代码示例来源: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: 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: mucommander/mucommander
/**
* Returns <code>true</code> if this MainFrame is active, or is an ancestor of a Window that is currently active.
*
* @return <code>true</code> if this MainFrame is active, or is an ancestor of a Window that is currently active
*/
public boolean isAncestorOfActiveWindow() {
if(isActive())
return true;
Window ownedWindows[] = getOwnedWindows();
int nbWindows = ownedWindows.length;
for(int i=0; i<nbWindows; i++)
if(ownedWindows[i].isActive())
return true;
return false;
}
代码示例来源:origin: stackoverflow.com
Window getSelectedWindow(Window[] windows) {
Window result = null;
for (int i = 0; i < windows.length; i++) {
Window window = windows[i];
if (window.isActive()) {
result = window;
} else {
Window[] ownedWindows = window.getOwnedWindows();
if (ownedWindows != null) {
result = getSelectedWindow(ownedWindows);
}
}
}
return result;
}
代码示例来源:origin: JetBrains/jediterm
@NotNull
public static Window getActiveWindow() {
Window[] windows = Window.getWindows();
for (Window each : windows) {
if (each.isVisible() && each.isActive()) return each;
}
return JOptionPane.getRootFrame();
}
代码示例来源:origin: com.github.insubstantial/substance
public static boolean isPaintRootPaneActivated(JRootPane rp) {
if (isRootPaneAutoDeactivate(rp)) {
Component c = rp.getParent();
if (c instanceof JInternalFrame) {
return ((JInternalFrame)c).isSelected();
} else if (c instanceof Window) {
return ((Window)c).isActive();
} else {
return false;
}
} else {
return true;
}
}
代码示例来源:origin: xSAVIKx/AndroidScreencast
@Override
public boolean dispatchKeyEvent(final KeyEvent e) {
if (!window.isActive())
return false;
if (e.getID() == KeyEvent.KEY_TYPED) {
final int code = KeyCodeConverter.getKeyCode(e);
SwingUtilities.invokeLater(() -> {
final KeyCommand command = getInputCommandFactory().getKeyCommand(code);
getCommandExecutor().execute(command);
});
}
return false;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/napkinlaf
@Override
public void addNotify() {
super.addNotify();
uninstallListeners();
window = SwingUtilities.getWindowAncestor(this);
if (window != null) {
if (window instanceof Frame) {
setState(((Frame) window).getExtendedState());
} else {
setState(0);
}
setActive(window.isActive());
installListeners();
}
}
内容来源于网络,如有侵权,请联系作者删除!