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


Java Frame.getGraphicsConfiguration方法代码示例

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


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

示例1: getCurrentGraphicsConfiguration

import java.awt.Frame; //导入方法依赖的package包/类
/**
    * 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();
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:Utilities.java

示例2: main

import java.awt.Frame; //导入方法依赖的package包/类
public static void main(String[] args) {
    boolean show = false;
    for (String arg : args) {
        if ("-show".equals(arg)) {
            show = true;
        }
    }

    String arch = System.getProperty("os.arch");
    boolean isOglEnabled = Boolean.getBoolean("sun.java2d.opengl");
    skipOglTextureTest = isOglEnabled && ("sparc".equals(arch));
    System.out.println("Skip OpenGL texture test: " + skipOglTextureTest);

    DrawImageBilinear test = new DrawImageBilinear();
    Frame frame = new Frame();
    frame.add(test);
    frame.pack();
    frame.setVisible(true);

    // Wait until the component's been painted
    synchronized (test) {
        while (!done) {
            try {
                test.wait();
            } catch (InterruptedException e) {
                throw new RuntimeException("Failed: Interrupted");
            }
        }
    }

    GraphicsConfiguration gc = frame.getGraphicsConfiguration();
    if (gc.getColorModel() instanceof IndexColorModel) {
        System.out.println("IndexColorModel detected: " +
                           "test considered PASSED");
        frame.dispose();
        return;
    }

    if (!show) {
        frame.dispose();
    }
    if (capture == null) {
        throw new RuntimeException("Failed: capture is null");
    }

    // Test background color
    int pixel = capture.getRGB(5, 5);
    if (pixel != 0xffffffff) {
        throw new RuntimeException("Failed: Incorrect color for " +
                                   "background");
    }

    // Test pixels
    testRegion(capture, new Rectangle(10, 10, 40, 40));
    testRegion(capture, new Rectangle(80, 10, 40, 40));
    testRegion(capture, new Rectangle(150, 10, 40, 40));
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:58,代码来源:DrawImageBilinear.java


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