本文整理汇总了Java中javax.swing.JFrame.isVisible方法的典型用法代码示例。如果您正苦于以下问题:Java JFrame.isVisible方法的具体用法?Java JFrame.isVisible怎么用?Java JFrame.isVisible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JFrame
的用法示例。
在下文中一共展示了JFrame.isVisible方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: waitForLoading
import javax.swing.JFrame; //导入方法依赖的package包/类
private void waitForLoading(final URL url, final JFrame f, final HtmlBrowser.Impl impl)
throws InvocationTargetException, InterruptedException {
for (int i = 0; i < 10 && f.isVisible(); i++) {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
URL current = impl.getURL();
if (url.equals(current)) {
f.setVisible(false);
f.dispose();
}
}
});
Thread.sleep(i*100);
}
}
示例2: create
import javax.swing.JFrame; //导入方法依赖的package包/类
/**
* creates a JFrame and a background Thread managing the rendering and the Frame itself.
*/
public static void create(){
if(!running){
running = true;
GFrame = new JFrame();
GFrame.setVisible(true);
RefreshWindow();
RegisterInputDevices();
BStrategy = GFrame.getBufferStrategy();
setCurrentscreen(new EmptyScreen());
PhySIX = new Thread(new Runnable(){
@Override
public void run() {
try {
while(GFrame.isVisible()){
Graphics g = BStrategy.getDrawGraphics();
clearScreen(g);
updateDHs(g);
renderDHs(g);
drawDHs(g);
drawmodels(g);
UpdateStrat(g);
Sync();
}
} catch (LessThanZeroException e) {
e.printStackTrace();
}
}
}, "Display-Loop-Thread.");
PhySIX.start();
}
}
示例3: saveScreenAndDimensions
import javax.swing.JFrame; //导入方法依赖的package包/类
private void saveScreenAndDimensions(JFrame frame) {
if (!frame.isVisible()) {
return;
}
// check multiple displays
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] screens = ge.getScreenDevices();
Point pos = frame.getLocationOnScreen();
Dimension size = frame.getSize();
if (screens.length == 1) {
Config.instance().to().setProperty(Config.Entry.POS_X.key(), pos.x);
Config.instance().to().setProperty(Config.Entry.POS_Y.key(), pos.y);
Config.instance().to().setProperty(Config.Entry.POS_WIDTH.key(), size.width);
Config.instance().to().setProperty(Config.Entry.POS_HEIGHT.key(), size.height);
logger.info("Saved window dimensions to config file (single screen found)");
} else {
Rectangle screenBounds = frame.getGraphicsConfiguration().getBounds();
pos.x -= screenBounds.x;
pos.y -= screenBounds.y;
GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
Config.instance().to().setProperty(Config.Entry.SCREEN_POS_X.key(), pos.x);
Config.instance().to().setProperty(Config.Entry.SCREEN_POS_Y.key(), pos.y);
Config.instance().to().setProperty(Config.Entry.SCREEN_POS_WIDTH.key(), size.width);
Config.instance().to().setProperty(Config.Entry.SCREEN_POS_HEIGHT.key(), size.height);
Config.instance().to().setProperty(Config.Entry.SCREEN.key(), device.getIDstring());
logger.info("Saved window dimensions to config file (multi screen found)");
}
}
示例4: isMatching
import javax.swing.JFrame; //导入方法依赖的package包/类
@Override
public boolean isMatching(JFrame frame) {
return frame.isVisible() && frame.getTitle().startsWith(textToMatch);
}
示例5: test
import javax.swing.JFrame; //导入方法依赖的package包/类
public static void test() {
// Right click Frame-1
robot.mouseMove(frame1.getLocation().x + 100, frame1.getLocation().y + 200);
robot.mousePress(InputEvent.BUTTON3_MASK);
robot.mouseRelease(InputEvent.BUTTON3_MASK);
robot.delay(1000);
// Left click Frame-2
robot.mouseMove(frame2.getLocation().x + 100, frame1.getLocation().y + 200);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.delay(1000);
JComponent focusOwner = (JComponent)KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
JFrame focusedWindow = (JFrame)KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
System.out.println("focus owner: " + focusOwner);
System.out.println("focused window: " + focusedWindow);
// Verify that the focused window is the ancestor of the focus owner
if (!focusedWindow.isAncestorOf(focusOwner)) {
throw new RuntimeException("The focus owner is not in the focused window!");
}
if (!OSInfo.getOSType().equals(OSInfo.OSType.MACOSX)) {
// Try to close native focused window
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_F4);
robot.keyRelease(KeyEvent.VK_F4);
robot.keyRelease(KeyEvent.VK_ALT);
robot.delay(1000);
// Verify that the Java focused window really mapped the native focused window.
if (focusedWindow.isVisible()) {
throw new RuntimeException("The focused window is different on Java and on the native level.");
}
} else {
// Try to move native focus to previous window
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_F4);
robot.keyRelease(KeyEvent.VK_F4);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.delay(1000);
// Verify that the Java focused window really mapped the native focused window.
if (focusedWindow.isFocused()) {
throw new RuntimeException("The focused window is different on Java and on the native level.");
}
}
}