当前位置: 首页>>代码示例>>Java>>正文


Java Frame.setExtendedState方法代码示例

本文整理汇总了Java中java.awt.Frame.setExtendedState方法的典型用法代码示例。如果您正苦于以下问题:Java Frame.setExtendedState方法的具体用法?Java Frame.setExtendedState怎么用?Java Frame.setExtendedState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Frame的用法示例。


在下文中一共展示了Frame.setExtendedState方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: topComponentToFront

import java.awt.Frame; //导入方法依赖的package包/类
/**
 * Attempts to bring the parent <code>Window</code> of the given <code>TopComponent</code>
 * to front of other windows.
 * @see java.awt.Window#toFront()
 * @since 5.8
 */
protected void topComponentToFront(TopComponent tc) {
    Window parentWindow = SwingUtilities.getWindowAncestor(tc);

    // be defensive, although w probably will always be non-null here
    if (null != parentWindow) {
        if (parentWindow instanceof Frame) {
            Frame parentFrame = (Frame) parentWindow;
            int state = parentFrame.getExtendedState();

            if ((state & Frame.ICONIFIED) > 0) {
                parentFrame.setExtendedState(state & ~Frame.ICONIFIED);
            }
        }

        parentWindow.toFront();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:WindowManager.java

示例2: main

import java.awt.Frame; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        Frame frame = new Frame();
        Robot robot = new Robot();
        final Toolkit toolkit = Toolkit.getDefaultToolkit();
        final GraphicsEnvironment graphicsEnvironment =
                GraphicsEnvironment.getLocalGraphicsEnvironment();
        final GraphicsDevice graphicsDevice =
                graphicsEnvironment.getDefaultScreenDevice();

        final Dimension screenSize = toolkit.getScreenSize();
        final Insets screenInsets = toolkit.getScreenInsets(
                graphicsDevice.getDefaultConfiguration());

        final Rectangle availableScreenBounds = new Rectangle(screenSize);

        availableScreenBounds.x += screenInsets.left;
        availableScreenBounds.y += screenInsets.top;
        availableScreenBounds.width -= (screenInsets.left + screenInsets.right);
        availableScreenBounds.height -= (screenInsets.top + screenInsets.bottom);

        frame.setBounds(availableScreenBounds.x, availableScreenBounds.y,
                availableScreenBounds.width, availableScreenBounds.height);
        frame.setVisible(true);
        robot.waitForIdle();

        Rectangle frameBounds = frame.getBounds();
        frame.setExtendedState(Frame.MAXIMIZED_BOTH);
        robot.waitForIdle();

        Rectangle maximizedFrameBounds = frame.getBounds();

        frame.dispose();
        if (maximizedFrameBounds.width < frameBounds.width
                || maximizedFrameBounds.height < frameBounds.height) {
            throw new RuntimeException("Maximized frame is smaller than non maximized");
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:MaximizedToMaximized.java

示例3: main

import java.awt.Frame; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
    Frame frame = new Frame("Frame Minimize Test");
    Button b = new Button("Focus ownder");
    frame.add("South", b);
    frame.pack();
    frame.setVisible(true);
    Util.waitForIdle(null);
    if (!b.hasFocus()) {
        throw new RuntimeException("button is not a focus owner after showing :(");
    }
    frame.setExtendedState(Frame.ICONIFIED);
    Util.waitForIdle(null);
    frame.setExtendedState(Frame.NORMAL);
    Util.waitForIdle(null);
    if (!b.hasFocus()) {
        throw new RuntimeException("button is not a focus owner after restoring :(");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:FrameMinimizeTest.java

示例4: doTest

import java.awt.Frame; //导入方法依赖的package包/类
boolean doTest() {
    Dimension beforeMaximizeCalled = new Dimension(300,300);

    frame = new Frame("Test Frame");
    frame.setUndecorated(true);
    frame.setFocusable(true);
    frame.setSize(beforeMaximizeCalled);
    frame.setVisible(true);
    frame.setExtendedState(Frame.MAXIMIZED_BOTH);
    frame.setExtendedState(Frame.NORMAL);

    Dimension afterMaximizedCalled= frame.getBounds().getSize();

    frame.dispose();

    if (beforeMaximizeCalled.equals(afterMaximizedCalled)) {
        return true;
    }
    return false;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:MaximizedNormalBoundsUndecoratedTest.java

示例5: main

import java.awt.Frame; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

       Frame frame = new Frame();
        final Toolkit toolkit = Toolkit.getDefaultToolkit();
        final GraphicsEnvironment graphicsEnvironment =
                GraphicsEnvironment.getLocalGraphicsEnvironment();
        final GraphicsDevice graphicsDevice =
                graphicsEnvironment.getDefaultScreenDevice();

        final Dimension screenSize = toolkit.getScreenSize();
        final Insets screenInsets = toolkit.getScreenInsets(
                graphicsDevice.getDefaultConfiguration());

        final Rectangle availableScreenBounds = new Rectangle(screenSize);

        availableScreenBounds.x += screenInsets.left;
        availableScreenBounds.y += screenInsets.top;
        availableScreenBounds.width -= (screenInsets.left + screenInsets.right);
        availableScreenBounds.height -= (screenInsets.top + screenInsets.bottom);

        frame.setBounds(availableScreenBounds.x, availableScreenBounds.y,
                availableScreenBounds.width, availableScreenBounds.height);
        frame.setVisible(true);

        Rectangle frameBounds = frame.getBounds();
        frame.setExtendedState(Frame.MAXIMIZED_BOTH);
        ((SunToolkit) toolkit).realSync();

        Rectangle maximizedFrameBounds = frame.getBounds();
        if (maximizedFrameBounds.width < frameBounds.width
                || maximizedFrameBounds.height < frameBounds.height) {
            throw new RuntimeException("Maximized frame is smaller than non maximized");
        }
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:35,代码来源:MaximizedToMaximized.java

示例6: createAWTComponents

import java.awt.Frame; //导入方法依赖的package包/类
private void createAWTComponents() {
    Frame f1 = new Frame("F1");
    f1.setBounds(100, 300, 100, 100);
    f1.setVisible(true);

    try {
        Thread.sleep(500);
    } catch (Exception ex) {
    }

    f1.setExtendedState(Frame.ICONIFIED);

    Frame g1 = new Frame("G1");
    g1.setBounds(150, 350, 100, 100);
    g1.setVisible(true);

    final Dialog d1 = new Dialog((Frame) null, "D1", Dialog.ModalityType.APPLICATION_MODAL);
    d1.setBounds(200, 400, 100, 100);
    new Thread(new Runnable() {
        public void run() {
            d1.setVisible(true);
        }
    }).start();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:InvisibleParentTest.java

示例7: frontMainWindow

import java.awt.Frame; //导入方法依赖的package包/类
private static void frontMainWindow() {
    Frame f = WindowManager.getDefault().getMainWindow();

    // makes sure the frame is visible
    f.setVisible(true);
    // uniconifies the frame if it is inconified
    if ((f.getExtendedState() & Frame.ICONIFIED) != 0) {
        f.setExtendedState(~Frame.ICONIFIED & f.getExtendedState());
    }
    // moves it to front and requests focus
    f.toFront ();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:CLIOptions2.java

示例8: main

import java.awt.Frame; //导入方法依赖的package包/类
public static void main(String[] args) {
    Frame frame = new Frame("frame");
    frame.setBounds(100, 100, 200, 200);
    frame.setVisible(true);
    frame.setExtendedState(Frame.MAXIMIZED_BOTH);
    frame.setExtendedState(Frame.ICONIFIED);
    if (frame.getExtendedState() != Frame.ICONIFIED) {
        frame.dispose();
        throw new RuntimeException("Test Failed");
    }
    frame.dispose();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:SetExtendedState.java

示例9: activateModeTopComponent

import java.awt.Frame; //导入方法依赖的package包/类
/** */
public void activateModeTopComponent(ModeImpl mode, TopComponent tc) {
    if(!getModeOpenedTopComponents(mode).contains(tc)) {
        return;
    }
    
    ModeImpl oldActiveMode = getActiveMode();
    //#45650 -some API users call the activation all over again all the time on one item.
    // improve performance for such cases.
    if (oldActiveMode != null && oldActiveMode.equals(mode)) {
        if (tc != null && tc.equals(model.getModeSelectedTopComponent(mode))) {
            // #82385, #139319 do repeat activation if focus is not
            // owned by tc to be activated
            Component fOwn = KeyboardFocusManager.getCurrentKeyboardFocusManager().
                    getFocusOwner();
            if (fOwn != null && SwingUtilities.isDescendingFrom(fOwn, tc)) {
                //#70173 - activation request came probably from a sliding
                //window in 'hover' mode, so let's hide it
                slideOutSlidingWindows( mode );
                return;
            }
        }
    }
    model.setActiveMode(mode);
    model.setModeSelectedTopComponent(mode, tc);
    
    if(isVisible()) {
        viewRequestor.scheduleRequest(new ViewRequest(mode, 
            View.CHANGE_TOPCOMPONENT_ACTIVATED, null, tc));

        //restore floating windows if iconified
        if( mode.getState() == Constants.MODE_STATE_SEPARATED ) {
            Frame frame = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, tc);
            if( null != frame && frame != WindowManagerImpl.getInstance().getMainWindow()
                    && (frame.getExtendedState() & Frame.ICONIFIED) > 0 ) {
                frame.setExtendedState(frame.getExtendedState() - Frame.ICONIFIED );
            }
        }
    }
    
    // Notify registry.
    WindowManagerImpl.notifyRegistryTopComponentActivated(tc);
    
    if(oldActiveMode != mode) {
        WindowManagerImpl.getInstance().doFirePropertyChange(
            WindowManagerImpl.PROP_ACTIVE_MODE, oldActiveMode, mode);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:49,代码来源:Central.java

示例10: main

import java.awt.Frame; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
    OSInfo.OSType type = OSInfo.getOSType();
    if (type != OSInfo.OSType.LINUX && type != OSInfo.OSType.SOLARIS) {
        System.out.println("This test is for Solaris and Linux only..." +
                           "skipping!");
        return;
    }

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    if (gds.length < 2) {
        System.out.println("It's a multi-screen test... skipping!");
        return;
    }

    for (int screen = 0; screen < gds.length; ++screen) {
        GraphicsDevice gd = gds[screen];
        GraphicsConfiguration gc = gd.getDefaultConfiguration();
        Rectangle bounds = gc.getBounds();
        Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);

        Frame frame = new Frame(gc);
        frame.setLocation(bounds.x + (bounds.width - SIZE) / 2,
                          bounds.y + (bounds.height - SIZE) / 2);
        frame.setSize(SIZE, SIZE);
        frame.setUndecorated(true);
        frame.setVisible(true);

        // Maximize Frame to reach the struts
        frame.setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);
        Thread.sleep(2000);

        Rectangle frameBounds = frame.getBounds();
        frame.dispose();
        if (bounds.x + insets.left != frameBounds.x
            || bounds.y + insets.top != frameBounds.y
            || bounds.width - insets.right - insets.left != frameBounds.width
            || bounds.height - insets.bottom - insets.top != frameBounds.height) {
            throw new RuntimeException("Test FAILED! Wrong screen #" +
                                       screen + " insets: " + insets);
        }
    }
    System.out.println("Test PASSED!");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:45,代码来源:MultiScreenInsetsTest.java

示例11: main

import java.awt.Frame; //导入方法依赖的package包/类
public static void main(String[] args) {
    Robot robot = Util.createRobot();

    Frame testFrame = new Frame("Test Frame");
    testFrame.setSize(200, 200);
    testFrame.addWindowStateListener(new WindowStateListener() {
        @Override
        public void windowStateChanged(WindowEvent e) {
            listenerNotified.set(true);
            synchronized (listenerNotified) {
                listenerNotified.notifyAll();
            }
        }
    });
    testFrame.setVisible(true);

    Frame mainFrame = new Frame("Main Frame");
    mainFrame.setSize(200, 200);
    mainFrame.setLocationRelativeTo(null);
    mainFrame.setVisible(true);

    Util.waitForIdle(robot);

    try {
        Util.clickOnComp(mainFrame, robot);
        Util.waitForIdle(robot);

        // NORMAL -> ICONIFIED
        listenerNotified.set(false);
        testFrame.setExtendedState(Frame.ICONIFIED);
        Util.waitForIdle(robot);

        Util.waitForCondition(listenerNotified, 2000);
        if (!listenerNotified.get()) {
            throw new RuntimeException("Test FAILED! Window state listener was not notified during NORMAL to" +
                    "ICONIFIED transition");
        }
        if (testFrame.getExtendedState() != Frame.ICONIFIED) {
            throw new RuntimeException("Test FAILED! Frame is not in ICONIFIED state");
        }

        // ICONIFIED -> NORMAL
        listenerNotified.set(false);
        testFrame.setExtendedState(Frame.NORMAL);
        Util.waitForIdle(robot);

        Util.waitForCondition(listenerNotified, 2000);
        if (!listenerNotified.get()) {
            throw new RuntimeException("Test FAILED! Window state listener was not notified during ICONIFIED to" +
                    "NORMAL transition");
        }
        if (testFrame.getExtendedState() != Frame.NORMAL) {
            throw new RuntimeException("Test FAILED! Frame is not in NORMAL state");
        }
    } finally {
        testFrame.dispose();
        mainFrame.dispose();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:60,代码来源:NormalToIconifiedTest.java


注:本文中的java.awt.Frame.setExtendedState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。