Java 类java.awt.Window 实例源码

项目:incubator-netbeans    文件:Utilities.java   
/**
    * Finds out the monitor where the user currently has the input focus.
    * This method is usually used to help the client code to figure out on
    * which monitor it should place newly created windows/frames/dialogs.
    *
    * @return the GraphicsConfiguration of the monitor which currently has the
    * input focus
    */
   private static GraphicsConfiguration getCurrentGraphicsConfiguration() {
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
       if (focusOwner != null) {
           Window w = SwingUtilities.getWindowAncestor(focusOwner);
           if (w != null) {
               return w.getGraphicsConfiguration();
           } else {
               //#217737 - try to find the main window which could be placed in secondary screen
               for( Frame f : Frame.getFrames() ) {
                   if( "NbMainWindow".equals(f.getName())) { //NOI18N
                       return f.getGraphicsConfiguration();
                   }
               }
           }
       }

       return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
   }
项目:AgentWorkbench    文件:OIDCAuthorization.java   
/**
 * Gets the authorization dialog.
 *
 * @param presetUsername username which should be shown preset when displaying the dialog
 * @param owner the window to which the dialog should belong (to center etc.)
 * @return the dialog
 */
public JDialog getDialog(String presetUsername, Window owner) {

    authDialog = new JDialog(owner);
    OIDCPanel oidcPanel = new OIDCPanel(this);
    if (presetUsername != null) {
        oidcPanel.getJTextFieldUsername().setText(presetUsername);
    }
    authDialog.setContentPane(oidcPanel);
    authDialog.setSize(new Dimension(500, 190));
    authDialog.setLocationRelativeTo(null);
    return authDialog;
}
项目:OpenJSharp    文件:D3DGraphicsDevice.java   
@Override
protected void addFSWindowListener(Window w) {
    // if the window is not a toplevel (has an owner) we have to use the
    // real toplevel to enter the full-screen mode with (4933099).
    if (!(w instanceof Frame) && !(w instanceof Dialog) &&
        (realFSWindow = getToplevelOwner(w)) != null)
    {
        ownerOrigBounds = realFSWindow.getBounds();
        WWindowPeer fp = (WWindowPeer)realFSWindow.getPeer();

        ownerWasVisible = realFSWindow.isVisible();
        Rectangle r = w.getBounds();
        // we use operations on peer instead of component because calling
        // them on component will take the tree lock
        fp.reshape(r.x, r.y, r.width, r.height);
        fp.setVisible(true);
    } else {
        realFSWindow = w;
    }

    fsWindowWasAlwaysOnTop = realFSWindow.isAlwaysOnTop();
    ((WWindowPeer)realFSWindow.getPeer()).setAlwaysOnTop(true);

    fsWindowListener = new D3DFSWindowAdapter();
    realFSWindow.addWindowListener(fsWindowListener);
}
项目:VASSAL-src    文件:PrivMsgCommand.java   
public void executeCommand() {
  PrivateChatter chat = mgr.getChatterFor(p);
  if (chat == null) {
    return;
  }

  Window f = SwingUtilities.getWindowAncestor(chat);
  if (!f.isVisible()) {
    f.setVisible(true);
    Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager()
                                      .getFocusOwner();
    if (c == null || !SwingUtilities.isDescendingFrom(c, f)) {
      java.awt.Toolkit.getDefaultToolkit().beep();
      for (int i = 0,j = chat.getComponentCount(); i < j; ++i) {
        if (chat.getComponent(i) instanceof JTextField) {
          (chat.getComponent(i)).requestFocus();
          break;
        }
      }
    }
  }
  else {
    f.toFront();
  }
  chat.show(msg);
}
项目:openjdk-jdk10    文件:GUIBrowser.java   
public WindowNode(Window win) {
    super(win);
    Window[] wns = win.getOwnedWindows();
    Vector<WindowNode> wwns = new Vector<>();
    for (Window wn : wns) {
        if (propDialog.showAll || wn.isVisible()) {
            wwns.add(new WindowNode(wn));
        }
    }
    wins = new WindowNode[wwns.size()];
    for (int i = 0; i < wwns.size(); i++) {
        wins[i] = wwns.get(i);
    }
    title = win.toString();
    clss = win.getClass().getName();
    BufferedImage image = null;
    try {
        image = new Robot().
                createScreenCapture(new Rectangle(win.getLocationOnScreen(),
                        win.getSize()));
    } catch (AWTException e) {
        e.printStackTrace();
    }
    setComponentImageProvider(new ComponentImageProvider(image, x, y));
}
项目:jdk8u-jdk    文件:LegacyGlueFocusTraversalPolicy.java   
private boolean accept(Component aComponent) {
    if (!(aComponent.isVisible() && aComponent.isDisplayable() &&
          aComponent.isFocusable() && aComponent.isEnabled())) {
        return false;
    }

    // Verify that the Component is recursively enabled. Disabling a
    // heavyweight Container disables its children, whereas disabling
    // a lightweight Container does not.
    if (!(aComponent instanceof Window)) {
        for (Container enableTest = aComponent.getParent();
             enableTest != null;
             enableTest = enableTest.getParent())
        {
            if (!(enableTest.isEnabled() || enableTest.isLightweight())) {
                return false;
            }
            if (enableTest instanceof Window) {
                break;
            }
        }
    }

    return true;
}
项目:powertext    文件:SizeGrip.java   
@Override
public void mouseDragged(MouseEvent e) {
    Point newPos = e.getPoint();
    SwingUtilities.convertPointToScreen(newPos, SizeGrip.this);
    int xDelta = newPos.x - origPos.x;
    int yDelta = newPos.y - origPos.y;
    Window wind = SwingUtilities.getWindowAncestor(SizeGrip.this);
    if (wind!=null) { // Should always be true
        if (getComponentOrientation().isLeftToRight()) {
            int w = wind.getWidth();
            if (newPos.x>=wind.getX()) {
                w += xDelta;
            }
            int h = wind.getHeight();
            if (newPos.y>=wind.getY()) {
                h += yDelta;
            }
            wind.setSize(w,h);
        }
        else { // RTL
            int newW = Math.max(1, wind.getWidth()-xDelta);
            int newH = Math.max(1, wind.getHeight()+yDelta);
            wind.setBounds(newPos.x, wind.getY(), newW, newH);
        }
        // invalidate()/validate() needed pre-1.6.
        wind.invalidate();
        wind.validate();
    }
    origPos.setLocation(newPos);
}
项目:VASSAL-src    文件:PieceWindow.java   
/**
 * Expects to be added to a {@link GameModule}.  When added, sets
 * the containing window to visible */
public void addTo(Buildable parent) {
  idMgr.add(this);

  if (!hidden) {
    String key = PositionOption.key + getConfigureName();
    if ("PieceWindow0".equals(id) && GlobalOptions.getInstance().isUseSingleWindow()) { //$NON-NLS-1$
      mainWindowDock = new ComponentSplitter().splitLeft(GameModule.getGameModule().getControlPanel(), root, false);
    }
    else {
      final Window w = initFrame();
      final PositionOption pos = new VisibilityOption(key, w);
      GameModule.getGameModule().getPrefs().addOption(pos);
    }
    GameModule.getGameModule().getToolBar().add(launch);
  }
  setAttributeTranslatable(NAME, false);
}
项目:incubator-netbeans    文件:NbPlatformCustomizer.java   
@Messages({
    "CTL_ModulesTab=Modules",
    "CTL_SourcesTab=Sources",
    "CTL_JavadocTab=Javadoc",
    "CTL_HarnessTab=Harness"
})
private void initTabs() {
    if (platformsList.getModel().getSize() > 0) {
        platformsList.setSelectedIndex(0);
        sourcesTab = new NbPlatformCustomizerSources();
        modulesTab = new NbPlatformCustomizerModules();
        javadocTab = new NbPlatformCustomizerJavadoc();
        harnessTab = new NbPlatformCustomizerHarness();
        detailPane.addTab(CTL_ModulesTab(), modulesTab);
        detailPane.addTab(CTL_SourcesTab(), sourcesTab);
        detailPane.addTab(CTL_JavadocTab(), javadocTab);
        detailPane.addTab(CTL_HarnessTab(), harnessTab);
        Container window = this.getTopLevelAncestor();
        if (window != null && window instanceof Window) {
            ((Window) window).pack();
        }
    }
}
项目:OpenJSharp    文件:X11GraphicsDevice.java   
private static void enterFullScreenExclusive(Window w) {
    X11ComponentPeer peer = (X11ComponentPeer)w.getPeer();
    if (peer != null) {
        enterFullScreenExclusive(peer.getContentWindow());
        peer.setFullScreenExclusiveModeState(true);
    }
}
项目:jdk8u-jdk    文件:X11GraphicsDevice.java   
private static void enterFullScreenExclusive(Window w) {
    X11ComponentPeer peer = (X11ComponentPeer)w.getPeer();
    if (peer != null) {
        enterFullScreenExclusive(peer.getWindow());
        peer.setFullScreenExclusiveModeState(true);
    }
}
项目:openjdk-jdk10    文件:FullScreenAfterSplash.java   
private static void enableFullScreen(Window window) {
    try {
        Class<?> fullScreenUtilities = Class.forName("com.apple.eawt.FullScreenUtilities");
        Method setWindowCanFullScreen = fullScreenUtilities.getMethod("setWindowCanFullScreen", Window.class, boolean.class);
        setWindowCanFullScreen.invoke(fullScreenUtilities, window, true);
        Class fullScreenListener = Class.forName("com.apple.eawt.FullScreenListener");
        Object listenerObject = Proxy.newProxyInstance(fullScreenListener.getClassLoader(), new Class[]{fullScreenListener}, (proxy, method, args) -> {
            switch (method.getName()) {
                case "windowEnteringFullScreen":
                    windowEnteringFullScreen = true;
                    break;
                case "windowEnteredFullScreen":
                    windowEnteredFullScreen = true;
                    break;
            }
            return null;
        });
        Method addFullScreenListener = fullScreenUtilities.getMethod("addFullScreenListenerTo", Window.class, fullScreenListener);
        addFullScreenListener.invoke(fullScreenUtilities, window, listenerObject);
    } catch (Exception e) {
        throw new RuntimeException("FullScreen utilities not available", e);
    }
}
项目:openjdk-jdk10    文件:PolicyTool.java   
/**
 * displays a dialog box describing the status of an event
 */
void displayStatusDialog(Window w, String status) {
    ToolDialog sd = new ToolDialog
            (PolicyTool.getMessage("Status"), tool, this, true);

    // find the location of the PolicyTool gui
    Point location = ((w == null) ?
            getLocationOnScreen() : w.getLocationOnScreen());
    //sd.setBounds(location.x + 50, location.y + 50, 500, 100);
    sd.setLayout(new GridBagLayout());

    JLabel label = new JLabel(status);
    addNewComponent(sd, label, 0,
                    0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH);

    JButton okButton = new JButton(PolicyTool.getMessage("OK"));
    ActionListener okListener = new StatusOKButtonListener(sd);
    okButton.addActionListener(okListener);
    addNewComponent(sd, okButton, 1,
                    0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL);

    sd.getRootPane().setDefaultButton(okButton);
    sd.getRootPane().registerKeyboardAction(okListener, escKey, JComponent.WHEN_IN_FOCUSED_WINDOW);

    sd.pack();
    sd.setLocationRelativeTo(w);
    sd.setVisible(true);
}
项目:incubator-netbeans    文件:TabControlButtonFactory.java   
@Override
public void addNotify() {
    super.addNotify();
    //#205194 - cannot minimize floating tab
    Window w = SwingUtilities.getWindowAncestor( displayer );
    boolean isFloating = w != WindowManager.getDefault().getMainWindow();
    if( isFloating )
        setVisible( false );
}
项目:OpenJSharp    文件:AncestorNotifier.java   
void addListeners(Component ancestor, boolean addToFirst) {
    Component a;

    firstInvisibleAncestor = null;
    for (a = ancestor;
         firstInvisibleAncestor == null;
         a = a.getParent()) {
        if (addToFirst || a != ancestor) {
            a.addComponentListener(this);

            if (a instanceof JComponent) {
                JComponent jAncestor = (JComponent)a;

                jAncestor.addPropertyChangeListener(this);
            }
        }
        if (!a.isVisible() || a.getParent() == null || a instanceof Window) {
            firstInvisibleAncestor = a;
        }
    }
    if (firstInvisibleAncestor instanceof Window &&
        firstInvisibleAncestor.isVisible()) {
        firstInvisibleAncestor = null;
    }
}
项目:openjdk-jdk10    文件:SetShapeTest.java   
private static void createUI() throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            background = new Frame();
            background.setUndecorated(true);
            background.setBackground(Color.blue);
            background.setSize(300, 300);
            background.setLocation(100, 100);
            background.setVisible(true);
            window = new Window(background);
            window.setBackground(Color.red);
            window.add(new Panel(), BorderLayout.CENTER);
            window.setLocation(200, 200);
            window.setSize(100, 100);
            Area a = new Area();
            a.add(new Area(new Rectangle2D.Double(0, 0, 100, 100)));
            window.setShape(a);
            window.setVisible(true);
            window.toFront();
        }
    });
}
项目:incubator-netbeans    文件:AutoResizingPanel.java   
private void enlargeAsNecessary(int currentWidth,
                                int currentHeight,
                                int requestedWidth,
                                int requestedHeight) {
    if ((currentWidth >= requestedWidth) && (currentHeight >= requestedHeight)) {
        /* the panel is large enough */
        return;
    }

    Window window = SwingUtilities.getWindowAncestor(this);
    if (window == null) {
        return;
    }

    try {
        requestedSize = new Dimension(requestedWidth, requestedHeight);
        window.pack();
    } finally {
        requestedSize = null;
    }
}
项目:incubator-netbeans    文件:UIHandler.java   
@Override
public void actionPerformed(ActionEvent ev) {
    JComponent c = (JComponent)ev.getSource();
    Window w = SwingUtilities.windowForComponent(c);
    if (w != null) {
        w.dispose();
    } 
    Installer.RP.post(this);
}
项目:openjdk-jdk10    文件:MultiMonPrintDlgTest.java   
private void executeTest() {

        GraphicsDevice defDev = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
        int x = 0;
        Frame f = null;
        for (x = 0; x < gd.length; x ++) {
            if (gd[x] != defDev) {
                secFrame = new Frame("Screen " + x + " - secondary", gd[x].getDefaultConfiguration());
                f = secFrame;
            } else {
                primaryFrame = new Frame("Screen " + x + " - primary", gd[x].getDefaultConfiguration());
                f = primaryFrame;
            }
            Button b = new Button("Print");
            b.addActionListener(this);
            f.add("South", b);
            f.addWindowListener (new WindowAdapter() {
                public void windowClosing(WindowEvent we) {
                    ((Window) we.getSource()).dispose();
                }
            });
            f.setSize(200, 200);
            f.setVisible(true);
        }
    }
项目:openjdk-jdk10    文件:XComponentPeer.java   
@SuppressWarnings("deprecation")
public boolean isObscured() {
    Container container  = (target instanceof Container) ?
        (Container)target : target.getParent();

    if (container == null) {
        return true;
    }

    Container parent;
    while ((parent = container.getParent()) != null) {
        container = parent;
    }

    if (container instanceof Window) {
        XWindowPeer wpeer = AWTAccessor.getComponentAccessor()
                                       .getPeer(container);
        if (wpeer != null) {
            return (wpeer.winAttr.visibilityState !=
                    XWindowAttributesData.AWT_UNOBSCURED);
        }
    }
    return true;
}
项目:incubator-netbeans    文件:DocumentsDlg.java   
public void removeNotify () {
    // save dialog size on click at [x] in titlebar
    Window dlg = SwingUtilities.getWindowAncestor(this);
    if( null != dlg )
        getDefault().previousDialogSize = dlg.getSize();
    super.removeNotify();
    explorer.removePropertyChangeListener(this);
}
项目:jdk8u-jdk    文件:JOptionPane.java   
private JDialog createDialog(Component parentComponent, String title,
        int style)
        throws HeadlessException {

    final JDialog dialog;

    Window window = JOptionPane.getWindowForComponent(parentComponent);
    if (window instanceof Frame) {
        dialog = new JDialog((Frame)window, title, true);
    } else {
        dialog = new JDialog((Dialog)window, title, true);
    }
    if (window instanceof SwingUtilities.SharedOwnerFrame) {
        WindowListener ownerShutdownListener =
                SwingUtilities.getSharedOwnerFrameShutdownListener();
        dialog.addWindowListener(ownerShutdownListener);
    }
    initDialog(dialog, style, parentComponent);
    return dialog;
}
项目:jdk8u-jdk    文件:InputContext.java   
private synchronized void addClientWindowListeners() {
    Component client = getClientComponent();
    if (client == null) {
        return;
    }
    Window window = getComponentWindow(client);
    if (window == null) {
        return;
    }
    window.addComponentListener(this);
    window.addWindowListener(this);
    clientWindowListened = window;
}
项目:jdk8u-jdk    文件:Win32GraphicsDevice.java   
@Override
public synchronized void setDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        super.setDisplayMode(dm);
        return;
    }
    if (dm == null || (dm = getMatchingDisplayMode(dm)) == null) {
        throw new IllegalArgumentException("Invalid display mode");
    }
    if (getDisplayMode().equals(dm)) {
        return;
    }
    Window w = getFullScreenWindow();
    if (w != null) {
        WWindowPeer peer = (WWindowPeer)w.getPeer();
        configDisplayMode(screen, peer, dm.getWidth(), dm.getHeight(),
            dm.getBitDepth(), dm.getRefreshRate());
        // resize the fullscreen window to the dimensions of the new
        // display mode
        Rectangle screenBounds = getDefaultConfiguration().getBounds();
        w.setBounds(screenBounds.x, screenBounds.y,
                    dm.getWidth(), dm.getHeight());
        // Note: no call to replaceSurfaceData is required here since
        // replacement will be caused by an upcoming display change event
    } else {
        throw new IllegalStateException("Must be in fullscreen mode " +
                                        "in order to set display mode");
    }
}
项目:Equella    文件:EditorHelper.java   
public static void listenForClosing(final Window window, final EditorInterface editor)
{
    if( window instanceof JFrame )
    {
        ((JFrame) window).setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    }

    if( window instanceof JDialog )
    {
        ((JDialog) window).setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    }

    window.addWindowListener(new WindowAdapter()
    {
        @Override
        public void windowClosing(WindowEvent e)
        {
            // If the spinner is showing, then something is happening and we
            // do not
            // want the window to be closed down.
            if( !editor.getStatusBar().isSpinnerVisible() )
            {
                if( !EditorHelper.onClose(editor, null) )
                {
                    return;
                }
            }
            window.setVisible(false);
            window.dispose();
        }
    });
}
项目:openjdk-jdk10    文件:Win32GraphicsDevice.java   
@Override
public synchronized void setDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        super.setDisplayMode(dm);
        return;
    }
    if (dm == null || (dm = getMatchingDisplayMode(dm)) == null) {
        throw new IllegalArgumentException("Invalid display mode");
    }
    if (getDisplayMode().equals(dm)) {
        return;
    }
    Window w = getFullScreenWindow();
    if (w != null) {
        WWindowPeer peer = AWTAccessor.getComponentAccessor().getPeer(w);
        configDisplayMode(screen, peer, dm.getWidth(), dm.getHeight(),
            dm.getBitDepth(), dm.getRefreshRate());
        // resize the fullscreen window to the dimensions of the new
        // display mode
        Rectangle screenBounds = getDefaultConfiguration().getBounds();
        w.setBounds(screenBounds.x, screenBounds.y,
                    dm.getWidth(), dm.getHeight());
        // Note: no call to replaceSurfaceData is required here since
        // replacement will be caused by an upcoming display change event
    } else {
        throw new IllegalStateException("Must be in fullscreen mode " +
                                        "in order to set display mode");
    }
}
项目:RxJava2Swing    文件:WindowEventObservable.java   
@Override
protected void onDispose(Window w) {
    int f = flags;
    if ((f & 1) != 0) {
        w.removeWindowListener(this);
    }
    if ((f & 2) != 0) {
        w.removeWindowFocusListener(this);
    }
    if ((f & 4) != 0) {
        w.removeWindowStateListener(this);
    }
}
项目:VASSAL-src    文件:FontConfigurer.java   
protected void updateValue() {
  final int style = Font.PLAIN |
     (bold.booleanValue().booleanValue() ? Font.BOLD : 0) |
     (italic.booleanValue().booleanValue() ? Font.ITALIC : 0);

  final OutlineFont font = new OutlineFont(
    (String) family.getSelectedItem(),
    style,
    Integer.parseInt(size.getValueString()),
    outline.booleanValue().booleanValue()
  );

  setValue(font);
  demo.setFont(font);

  final Window w = SwingUtilities.getWindowAncestor(getControls());
  if (w != null) {
    w.pack();
  }
}
项目:openjdk-jdk10    文件:Test6541987.java   
public static void main(String[] args) throws AWTException {
    robot = new Robot();
    // test escape after selection
    start();
    click(KeyEvent.VK_ESCAPE);
    robot.waitForIdle();
    // test double escape after editing
    start();
    click(KeyEvent.VK_1);
    click(KeyEvent.VK_0);
    click(KeyEvent.VK_ESCAPE);
    click(KeyEvent.VK_ESCAPE);
    robot.waitForIdle();
    // all windows should be closed
    for (Window window : Window.getWindows()) {
        if (window.isVisible()) {
            throw new Error("found visible window: " + window.getName());
        }
    }
}
项目:openjdk-jdk10    文件:JPopupMenuOperator.java   
/**
 * Waits for a window which contains JPopupMenu.
 *
 * @param chooser a component chooser specifying criteria for JPopupMenu.
 * @return a window containing JPopupMenu.
 * @throws TimeoutExpiredException
 */
public static Window waitJPopupWindow(ComponentChooser chooser) {
    try {
        return (new WindowWaiter()).waitWindow(new JPopupWindowFinder(chooser));
    } catch (InterruptedException e) {
        return null;
    }
}
项目:jdk8u-jdk    文件:XComponentPeer.java   
/****** DropTargetPeer implementation ********************/

    public void addDropTarget(DropTarget dt) {
        Component comp = target;
        while(!(comp == null || comp instanceof Window)) {
            comp = comp.getParent();
        }

        if (comp instanceof Window) {
            XWindowPeer wpeer = (XWindowPeer)(comp.getPeer());
            if (wpeer != null) {
                wpeer.addDropTarget();
            }
        }
    }
项目:openjdk-jdk10    文件:LWMouseInfoPeer.java   
@Override
public boolean isWindowUnderMouse(Window w) {
    if (w == null) {
        return false;
    }

    LWWindowPeer windowPeer = AWTAccessor.getComponentAccessor().getPeer(w);
    if (windowPeer == null) {
        return false;
    }

    return LWToolkit.getLWToolkit().getPlatformWindowUnderMouse() == windowPeer.getPlatformWindow();
}
项目:QN-ACTR-Release    文件:Manager.java   
/**
 * Adds a new Window to be checked for termination before terminating JVM
 * @param application application to be checked
 */
public static void addWindow(Window application) {
    if (!windows.contains(application)) {
        synchronized (windows) {
            if (!windows.contains(application)) {
                windows.add(application);
            }
        }
    }
}
项目:incubator-netbeans    文件:ConnectPanel.java   
/**
 * Refreshes panel with options corresponding to the selected connector type.
 * This method is called when a user selects new connector type.
 */
@Override
public void actionPerformed (ActionEvent e) {
    int selectedIndex = ((JComboBox) e.getSource ()).getSelectedIndex ();
    refresh (selectedIndex, Properties.getDefault ().getProperties ("debugger"));
    Window w = SwingUtilities.getWindowAncestor(this);
    if (w != null) {
        w.pack ();  // ugly hack...
    }
}
项目:openjdk-jdk10    文件:D3DSurfaceData.java   
@Override
void restoreSurface() {
    if (!peer.isAccelCapable()) {
        throw new InvalidPipeException("Onscreen acceleration " +
                                       "disabled for this surface");
    }
    Window fsw = graphicsDevice.getFullScreenWindow();
    if (fsw != null && fsw != peer.getTarget()) {
        throw new InvalidPipeException("Can't restore onscreen surface"+
                                       " when in full-screen mode");
    }
    super.restoreSurface();
    // if initialization was unsuccessful, an IPE will be thrown
    // and the surface will remain lost
    setSurfaceLost(false);

    // This is to make sure the render target is reset after this
    // surface is restored. The reason for this is that sometimes this
    // surface can be restored from multiple threads (the screen update
    // manager's thread and app's rendering thread) at the same time,
    // and when that happens the second restoration will create the
    // native resource which will not be set as render target because
    // the BufferedContext's validate method will think that since the
    // surface data object didn't change then the current render target
    // is correct and no rendering will appear on the screen.
    D3DRenderQueue rq = D3DRenderQueue.getInstance();
    rq.lock();
    try {
        getContext().invalidateContext();
    } finally {
        rq.unlock();
    }
}
项目:openjdk-jdk10    文件:JComponentOperator.java   
/**
 * Looks for a first window-like container.
 *
 * @return either WindowOperator of JInternalFrameOperator
 */
public ContainerOperator<?> getWindowContainerOperator() {
    Component resultComp;
    if (getSource() instanceof Window) {
        resultComp = getSource();
    } else {
        resultComp = getContainer(new ComponentChooser() {
            @Override
            public boolean checkComponent(Component comp) {
                return (comp instanceof Window
                        || comp instanceof JInternalFrame);
            }

            @Override
            public String getDescription() {
                return "";
            }
        });
    }
    ContainerOperator<?> result;
    if (resultComp instanceof Window) {
        result = new WindowOperator((Window) resultComp);
    } else {
        result = new ContainerOperator<>((Container) resultComp);
    }
    result.copyEnvironment(this);
    return result;
}
项目:QN-ACTR-Release    文件:AboutDialogFactory.java   
/**
 * Shows JABA about window
 * @param owner owner of this window (if null, window will not be modal)
 */
public static void showJABA(Window owner) {
    title.setText(TITLE_START + "JABA" + TITLE_END);
    title.setIcon(JMTImageLoader.loadImage(GraphStartScreen.IMG_JABAICON, new Dimension(50, 50)));
    addNames(JABA);
    createDialog(owner, "About JABA").show();
}
项目:QN-ACTR-Release    文件:AboutDialogFactory.java   
/**
 * Creates a new modal JMTDialog with specified owner and with panel inside, displaying current text.
 * @param owner owner of the dialog. If it's null or invalid, created dialog will not
 * be modal
 * @param title title of dialog to be created
 * @return created dialog
 */
protected static JMTDialog createDialog(Window owner, String title) {
    final JMTDialog dialog;
    if (owner == null) {
        dialog = new JMTDialog();
    } else if (owner instanceof Dialog) {
        dialog = new JMTDialog((Dialog) owner, true);
    } else if (owner instanceof Frame) {
        dialog = new JMTDialog((Frame) owner, true);
    } else {
        dialog = new JMTDialog();
    }
    dialog.setTitle(title);
    dialog.getContentPane().setLayout(new BorderLayout());
    dialog.getContentPane().add(panel, BorderLayout.CENTER);

    // Sets text to be displayed
    textArea.setText("<html><p><font size=\"-1\">" + WEBSITE + "<br><br>" + text + "</font></p></html>");

    // Adds exit button
    JButton exit = new JButton();
    exit.setText("Close");
    exit.addActionListener(new ActionListener() {

        /**
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            dialog.close();
        }
    });

    JPanel bottom = new JPanel();
    bottom.add(exit);
    dialog.getContentPane().add(bottom, BorderLayout.SOUTH);
    dialog.centerWindow(450, 500);
    return dialog;
}
项目:VASSAL-src    文件:InstanceConfigurer.java   
public void repack() {
  if (panel != null) {
    Window w = SwingUtilities.getWindowAncestor(panel);
    if (w != null) {
      w.pack();
    }
  }
  rebuildViz();
}
项目:incubator-netbeans    文件:ProfilerPopup.java   
private static ProfilerPopup create(Component invoker, Component content, int x, int y, int popupAlign, int resizeMode, Listener listener) {
    Point location = new Point(x, y);
    Dimension size = new Dimension();
    Window owner = null;

    if (invoker != null) {
        SwingUtilities.convertPointToScreen(location, invoker);
        size.setSize(invoker.getSize());
        owner = SwingUtilities.getWindowAncestor(invoker);
    }

    return new ProfilerPopup(content, new Rectangle(location, size), popupAlign, owner, resizeMode, listener);
}