Java Code Examples for java.awt.Frame#isVisible()

The following examples show how to use java.awt.Frame#isVisible() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: _AppMenuBarHandler.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
void setDefaultMenuBar(final JMenuBar menuBar) {
    installDefaultMenuBar(menuBar);

    // scan the current frames, and see if any are foreground
    final Frame[] frames = Frame.getFrames();
    for (final Frame frame : frames) {
        if (frame.isVisible() && !isFrameMinimized(frame)) {
            return;
        }
    }

    // if we have no foreground frames, then we have to "kick" the menubar
    final JFrame pingFrame = new JFrame();
    pingFrame.getRootPane().putClientProperty("Window.alpha", new Float(0.0f));
    pingFrame.setUndecorated(true);
    pingFrame.setVisible(true);
    pingFrame.toFront();
    pingFrame.setVisible(false);
    pingFrame.dispose();
}
 
Example 2
Source File: _AppMenuBarHandler.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
void setDefaultMenuBar(final JMenuBar menuBar) {
    installDefaultMenuBar(menuBar);

    // scan the current frames, and see if any are foreground
    final Frame[] frames = Frame.getFrames();
    for (final Frame frame : frames) {
        if (frame.isVisible() && !isFrameMinimized(frame)) {
            return;
        }
    }

    // if we have no foreground frames, then we have to "kick" the menubar
    final JFrame pingFrame = new JFrame();
    pingFrame.getRootPane().putClientProperty("Window.alpha", new Float(0.0f));
    pingFrame.setUndecorated(true);
    pingFrame.setVisible(true);
    pingFrame.toFront();
    pingFrame.setVisible(false);
    pingFrame.dispose();
}
 
Example 3
Source File: _AppMenuBarHandler.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
void setDefaultMenuBar(final JMenuBar menuBar) {
    installDefaultMenuBar(menuBar);

    // scan the current frames, and see if any are foreground
    final Frame[] frames = Frame.getFrames();
    for (final Frame frame : frames) {
        if (frame.isVisible() && !isFrameMinimized(frame)) {
            return;
        }
    }

    // if we have no foreground frames, then we have to "kick" the menubar
    final JFrame pingFrame = new JFrame();
    pingFrame.getRootPane().putClientProperty("Window.alpha", new Float(0.0f));
    pingFrame.setUndecorated(true);
    pingFrame.setVisible(true);
    pingFrame.toFront();
    pingFrame.setVisible(false);
    pingFrame.dispose();
}
 
Example 4
Source File: WindowsMenu.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
public void menuSelected(MenuEvent event) {

    // Remove all previous items
    while (getItemCount() > 2)
      remove(2);

    int windowsAdded = 0;
    // Create a menu item for each window
    for (Frame window : Frame.getFrames()) {

      if (window.isVisible()) {
        FrameMenuItem newItem = new FrameMenuItem(window, this);
        add(newItem);
        windowsAdded++;
      }
    }

    // Disable the Close all button if we only have the main window
    closeAllMenuItem.setEnabled(windowsAdded > 1);
  }
 
Example 5
Source File: _AppMenuBarHandler.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
void setDefaultMenuBar(final JMenuBar menuBar) {
    installDefaultMenuBar(menuBar);

    // scan the current frames, and see if any are foreground
    final Frame[] frames = Frame.getFrames();
    for (final Frame frame : frames) {
        if (frame.isVisible() && !isFrameMinimized(frame)) {
            return;
        }
    }

    // if we have no foreground frames, then we have to "kick" the menubar
    final JFrame pingFrame = new JFrame();
    pingFrame.getRootPane().putClientProperty("Window.alpha", new Float(0.0f));
    pingFrame.setUndecorated(true);
    pingFrame.setVisible(true);
    pingFrame.toFront();
    pingFrame.setVisible(false);
    pingFrame.dispose();
}
 
Example 6
Source File: _AppMenuBarHandler.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
void setDefaultMenuBar(final JMenuBar menuBar) {
    installDefaultMenuBar(menuBar);

    // scan the current frames, and see if any are foreground
    final Frame[] frames = Frame.getFrames();
    for (final Frame frame : frames) {
        if (frame.isVisible() && !isFrameMinimized(frame)) {
            return;
        }
    }

    // if we have no foreground frames, then we have to "kick" the menubar
    final JFrame pingFrame = new JFrame();
    pingFrame.getRootPane().putClientProperty("Window.alpha", new Float(0.0f));
    pingFrame.setUndecorated(true);
    pingFrame.setVisible(true);
    pingFrame.toFront();
    pingFrame.setVisible(false);
    pingFrame.dispose();
}
 
Example 7
Source File: _AppMenuBarHandler.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
void setDefaultMenuBar(final JMenuBar menuBar) {
    installDefaultMenuBar(menuBar);

    // scan the current frames, and see if any are foreground
    final Frame[] frames = Frame.getFrames();
    for (final Frame frame : frames) {
        if (frame.isVisible() && !isFrameMinimized(frame)) {
            return;
        }
    }

    // if we have no foreground frames, then we have to "kick" the menubar
    final JFrame pingFrame = new JFrame();
    pingFrame.getRootPane().putClientProperty("Window.alpha", new Float(0.0f));
    pingFrame.setUndecorated(true);
    pingFrame.setVisible(true);
    pingFrame.toFront();
    pingFrame.setVisible(false);
    pingFrame.dispose();
}
 
Example 8
Source File: _AppMenuBarHandler.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
void setDefaultMenuBar(final JMenuBar menuBar) {
    installDefaultMenuBar(menuBar);

    // scan the current frames, and see if any are foreground
    final Frame[] frames = Frame.getFrames();
    for (final Frame frame : frames) {
        if (frame.isVisible() && !isFrameMinimized(frame)) {
            return;
        }
    }

    // if we have no foreground frames, then we have to "kick" the menubar
    final JFrame pingFrame = new JFrame();
    pingFrame.getRootPane().putClientProperty("Window.alpha", new Float(0.0f));
    pingFrame.setUndecorated(true);
    pingFrame.setVisible(true);
    pingFrame.toFront();
    pingFrame.setVisible(false);
    pingFrame.dispose();
}
 
Example 9
Source File: _AppMenuBarHandler.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
void setDefaultMenuBar(final JMenuBar menuBar) {
    installDefaultMenuBar(menuBar);

    // scan the current frames, and see if any are foreground
    final Frame[] frames = Frame.getFrames();
    for (final Frame frame : frames) {
        if (frame.isVisible() && !isFrameMinimized(frame)) {
            return;
        }
    }

    // if we have no foreground frames, then we have to "kick" the menubar
    final JFrame pingFrame = new JFrame();
    pingFrame.getRootPane().putClientProperty("Window.alpha", new Float(0.0f));
    pingFrame.setUndecorated(true);
    pingFrame.setVisible(true);
    pingFrame.toFront();
    pingFrame.setVisible(false);
    pingFrame.dispose();
}
 
Example 10
Source File: _AppMenuBarHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
void setDefaultMenuBar(final JMenuBar menuBar) {
    installDefaultMenuBar(menuBar);

    // scan the current frames, and see if any are foreground
    final Frame[] frames = Frame.getFrames();
    for (final Frame frame : frames) {
        if (frame.isVisible() && !isFrameMinimized(frame)) {
            return;
        }
    }

    // if we have no foreground frames, then we have to "kick" the menubar
    final JFrame pingFrame = new JFrame();
    pingFrame.getRootPane().putClientProperty("Window.alpha", Float.valueOf(0.0f));
    pingFrame.setUndecorated(true);
    pingFrame.setVisible(true);
    pingFrame.toFront();
    pingFrame.setVisible(false);
    pingFrame.dispose();
}
 
Example 11
Source File: _AppMenuBarHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
void setDefaultMenuBar(final JMenuBar menuBar) {
    installDefaultMenuBar(menuBar);

    // scan the current frames, and see if any are foreground
    final Frame[] frames = Frame.getFrames();
    for (final Frame frame : frames) {
        if (frame.isVisible() && !isFrameMinimized(frame)) {
            return;
        }
    }

    // if we have no foreground frames, then we have to "kick" the menubar
    final JFrame pingFrame = new JFrame();
    pingFrame.getRootPane().putClientProperty("Window.alpha", new Float(0.0f));
    pingFrame.setUndecorated(true);
    pingFrame.setVisible(true);
    pingFrame.toFront();
    pingFrame.setVisible(false);
    pingFrame.dispose();
}
 
Example 12
Source File: _AppMenuBarHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
void setDefaultMenuBar(final JMenuBar menuBar) {
    installDefaultMenuBar(menuBar);

    // scan the current frames, and see if any are foreground
    final Frame[] frames = Frame.getFrames();
    for (final Frame frame : frames) {
        if (frame.isVisible() && !isFrameMinimized(frame)) {
            return;
        }
    }

    // if we have no foreground frames, then we have to "kick" the menubar
    final JFrame pingFrame = new JFrame();
    pingFrame.getRootPane().putClientProperty("Window.alpha", new Float(0.0f));
    pingFrame.setUndecorated(true);
    pingFrame.setVisible(true);
    pingFrame.toFront();
    pingFrame.setVisible(false);
    pingFrame.dispose();
}
 
Example 13
Source File: _AppMenuBarHandler.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
void setDefaultMenuBar(final JMenuBar menuBar) {
    installDefaultMenuBar(menuBar);

    // scan the current frames, and see if any are foreground
    final Frame[] frames = Frame.getFrames();
    for (final Frame frame : frames) {
        if (frame.isVisible() && !isFrameMinimized(frame)) {
            return;
        }
    }

    // if we have no foreground frames, then we have to "kick" the menubar
    final JFrame pingFrame = new JFrame();
    pingFrame.getRootPane().putClientProperty("Window.alpha", new Float(0.0f));
    pingFrame.setUndecorated(true);
    pingFrame.setVisible(true);
    pingFrame.toFront();
    pingFrame.setVisible(false);
    pingFrame.dispose();
}
 
Example 14
Source File: _AppMenuBarHandler.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
void setDefaultMenuBar(final JMenuBar menuBar) {
    installDefaultMenuBar(menuBar);

    // scan the current frames, and see if any are foreground
    final Frame[] frames = Frame.getFrames();
    for (final Frame frame : frames) {
        if (frame.isVisible() && !isFrameMinimized(frame)) {
            return;
        }
    }

    // if we have no foreground frames, then we have to "kick" the menubar
    final JFrame pingFrame = new JFrame();
    pingFrame.getRootPane().putClientProperty("Window.alpha", new Float(0.0f));
    pingFrame.setUndecorated(true);
    pingFrame.setVisible(true);
    pingFrame.toFront();
    pingFrame.setVisible(false);
    pingFrame.dispose();
}
 
Example 15
Source File: WindowList.java    From pumpernickel with MIT License 5 votes vote down vote up
/**
 * Returns a list of frames.
 * 
 * @param sortByLayer
 *            whether to sort by layer or origin. If this is true, then the
 *            lowest index corresponds to the frame farthest behind; the
 *            highest index represents the highest frame. If this is false,
 *            then the lowest index corresponds to the first frame
 *            activated, and the highest index is the most recently
 *            activated frame.
 * @param includeInvisible
 *            if this is false then visible Frames will be returned. If this
 *            is true then all Frames will be returned, so the next argument
 *            is meaningless.
 * @param includeIconified
 *            if this is true then iconified Frames will be returned.
 */
public static Frame[] getFrames(boolean sortByLayer,
		boolean includeInvisible, boolean includeIconified) {
	ArrayList<WeakReference<Window>> list = sortByLayer ? windowLayerList
			: windowList;
	List<Frame> returnValue = new ArrayList<Frame>();
	int a = 0;
	while (a < list.size()) {
		WeakReference<Window> r = list.get(a);
		Window w = r.get();
		if (w == null) {
			list.remove(a);
		} else {
			if (w instanceof Frame) {
				Frame f = (Frame) w;
				if (includeInvisible || f.isVisible()) {
					returnValue.add(f);
				} else if (includeIconified
						&& f.getExtendedState() == Frame.ICONIFIED) {
					returnValue.add(f);
				}
			}
			a++;
		}
	}
	return returnValue.toArray(new Frame[returnValue.size()]);
}
 
Example 16
Source File: PbemDiceRoller.java    From triplea with GNU General Public License v3.0 5 votes vote down vote up
private static Frame getFocusedFrame() {
  final Frame[] frames = Frame.getFrames();
  Frame focusedFrame = null;
  for (final Frame frame : frames) {
    // find the window with focus, failing that, get something that is visible
    if (frame.isFocused() || (focusedFrame == null && frame.isVisible())) {
      focusedFrame = frame;
    }
  }
  return focusedFrame;
}
 
Example 17
Source File: Utils.java    From beast-mcmc with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static Frame getActiveFrame() {
	Frame result = null;
	Frame[] frames = Frame.getFrames();
	for (int i = 0; i < frames.length; i++) {
		Frame frame = frames[i];
		if (frame.isVisible()) {
			result = frame;
			break;
		}
	}
	return result;
}
 
Example 18
Source File: ConfigMenu.java    From log-requests-to-sqlite with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get a reference on the BURP main frame.
 *
 * @return BURP main frame.
 * @see "https://github.com/PortSwigger/param-miner/blob/master/src/burp/Utilities.java"
 */
static JFrame getBurpFrame() {
    for (Frame f : Frame.getFrames()) {
        if (f.isVisible() && f.getTitle().startsWith(("Burp Suite"))) {
            return (JFrame) f;
        }
    }
    return null;
}