當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。