Java 类java.awt.GraphicsEnvironment 实例源码

项目:jdk8u-jdk    文件:DisplayChangeVITest.java   
public static void main(String[] args) throws Exception {
    DisplayChangeVITest test = new DisplayChangeVITest();
    GraphicsDevice gd =
        GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice();
    if (gd.isFullScreenSupported()) {
        gd.setFullScreenWindow(test);
        Thread t = new Thread(test);
        t.run();
        synchronized (lock) {
            while (!done) {
                try {
                    lock.wait(50);
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
                }
            }
        }
        System.err.println("Test Passed.");
    } else {
        System.err.println("Full screen not supported. Test passed.");
    }
}
项目:OpenJSharp    文件:SurfaceManager.java   
public boolean isAccelerated() {
    // Note that when img.getAccelerationPriority() gets set to 0
    // we remove SurfaceDataProxy objects from the cache and the
    // answer will be false.
    GraphicsConfiguration tmpGc = gc;
    if (tmpGc == null) {
        tmpGc = GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice().getDefaultConfiguration();
    }
    if (tmpGc instanceof ProxiedGraphicsConfig) {
        Object proxyKey =
            ((ProxiedGraphicsConfig) tmpGc).getProxyKey();
        if (proxyKey != null) {
            SurfaceDataProxy sdp =
                (SurfaceDataProxy) getCacheData(proxyKey);
            return (sdp != null && sdp.isAccelerated());
        }
    }
    return false;
}
项目:Cognizant-Intelligent-Test-Scripter    文件:Canvas.java   
public static Image iconToImage(Icon icon) {
    if (icon instanceof ImageIcon) {
        return ((ImageIcon) icon).getImage();
    } else {
        int w = icon.getIconWidth();
        int h = icon.getIconHeight();
        GraphicsEnvironment ge
                = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice gd = ge.getDefaultScreenDevice();
        GraphicsConfiguration gc = gd.getDefaultConfiguration();
        BufferedImage image = gc.createCompatibleImage(w, h);
        Graphics2D g = image.createGraphics();
        icon.paintIcon(null, g, 0, 0);
        g.dispose();
        return image;
    }
}
项目:jdk8u-jdk    文件:RenderingToCachedGraphicsTest.java   
public static void main(String[] args) {
    int depth = GraphicsEnvironment.getLocalGraphicsEnvironment().
        getDefaultScreenDevice().getDefaultConfiguration().
            getColorModel().getPixelSize();
    if (depth < 16) {
        System.out.println("Test PASSED (depth < 16bit)");
        return;
    }

    latch = new CountDownLatch(1);
    RenderingToCachedGraphicsTest t1 = new RenderingToCachedGraphicsTest();
    t1.pack();
    t1.setSize(300, 300);
    t1.setVisible(true);

    try { latch.await(); } catch (InterruptedException ex) {}
    t1.dispose();

    if (failed) {
        throw new
            RuntimeException("Failed: rendering didn't show up");
    }
    System.out.println("Test PASSED");
}
项目:incubator-netbeans    文件:BasicTabDisplayerUI.java   
@Override
public Image createImageOfTab(int index) {
    TabData td = displayer.getModel().getTab(index);

    JLabel lbl = new JLabel(td.getText());
    int width = lbl.getFontMetrics(lbl.getFont()).stringWidth(td.getText());
    int height = lbl.getFontMetrics(lbl.getFont()).getHeight();
    width = width + td.getIcon().getIconWidth() + 6;
    height = Math.max(height, td.getIcon().getIconHeight()) + 5;

    GraphicsConfiguration config = GraphicsEnvironment.getLocalGraphicsEnvironment()
                                    .getDefaultScreenDevice().getDefaultConfiguration();

    BufferedImage image = config.createCompatibleImage(width, height);
    Graphics2D g = image.createGraphics();
    g.setColor(lbl.getForeground());
    g.setFont(lbl.getFont());
    td.getIcon().paintIcon(lbl, g, 0, 0);
    g.drawString(td.getText(), 18, height / 2);


    return image;
}
项目:openjdk-jdk10    文件:CheckDisplayModes.java   
public static void main(String[] args) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice graphicDevice = ge.getDefaultScreenDevice();
    if (!graphicDevice.isDisplayChangeSupported()) {
        System.err.println("Display mode change is not supported on this host. Test is considered passed.");
        return;
    }
    DisplayMode defaultDisplayMode = graphicDevice.getDisplayMode();
    checkDisplayMode(defaultDisplayMode);
    graphicDevice.setDisplayMode(defaultDisplayMode);

    DisplayMode[] displayModes = graphicDevice.getDisplayModes();
    boolean isDefaultDisplayModeIncluded = false;
    for (DisplayMode displayMode : displayModes) {
        checkDisplayMode(displayMode);
        graphicDevice.setDisplayMode(displayMode);
        if (defaultDisplayMode.equals(displayMode)) {
            isDefaultDisplayModeIncluded = true;
        }
    }

    if (!isDefaultDisplayModeIncluded) {
        throw new RuntimeException("Default display mode is not included");
    }
}
项目:incubator-netbeans    文件:NbiDialog.java   
public void setVisible(boolean visible) {
    if (owner == null) {
        final GraphicsDevice screen = GraphicsEnvironment.
                getLocalGraphicsEnvironment().
                getScreenDevices()[0];
        final GraphicsConfiguration config = screen.getDefaultConfiguration();

        final int screenWidth  = config.getBounds().width;
        final int screenHeight = config.getBounds().height;

        setLocation(
                (screenWidth - getSize().width) / 2,
                (screenHeight - getSize().height) / 2);
    } else {
        setLocation(
                owner.getLocation().x + DIALOG_FRAME_WIDTH_DELTA,
                owner.getLocation().y + DIALOG_FRAME_WIDTH_DELTA);
    }

    super.setVisible(visible);
}
项目:powertext    文件:TipUtil.java   
/**
 * Returns the screen coordinates for the monitor that contains the
 * specified point.  This is useful for setups with multiple monitors,
 * to ensure that popup windows are positioned properly.
 *
 * @param x The x-coordinate, in screen coordinates.
 * @param y The y-coordinate, in screen coordinates.
 * @return The bounds of the monitor that contains the specified point.
 */
public static Rectangle getScreenBoundsForPoint(int x, int y) {
    GraphicsEnvironment env = GraphicsEnvironment.
                                    getLocalGraphicsEnvironment();
    GraphicsDevice[] devices = env.getScreenDevices();
    for (int i=0; i<devices.length; i++) {
        GraphicsConfiguration[] configs = devices[i].getConfigurations();
        for (int j=0; j<configs.length; j++) {
            Rectangle gcBounds = configs[j].getBounds();
            if (gcBounds.contains(x, y)) {
                return gcBounds;
            }
        }
    }
    // If point is outside all monitors, default to default monitor (?)
    return env.getMaximumWindowBounds();
}
项目:jdk8u-jdk    文件:VolatileImageBug.java   
public static void main(String[] args) {

        boolean iaeThrown = false;
        GraphicsEnvironment ge = GraphicsEnvironment.
                                      getLocalGraphicsEnvironment();
        GraphicsConfiguration gc = ge.getDefaultScreenDevice().
                                           getDefaultConfiguration();
        try {
            VolatileImage volatileImage = gc.createCompatibleVolatileImage(0, 0);
        } catch (IllegalArgumentException iae) {
            iaeThrown = true;
        }
        if (!iaeThrown) {
            throw new RuntimeException ("IllegalArgumentException not thrown " +
                                        "for createCompatibleVolatileImage(0,0)");
        }
    }
项目:LeagueStats    文件:Assets.java   
/**
 * Initializes the fonts for this application.
 */
private static void initFonts() {
    final String extension = ".ttf";
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();

    try {
        ge.registerFont(Font.createFont(Font.TRUETYPE_FONT,
                new File(FONT_FILE_PATH + CAVIAR_FONT_NAME.replace(" ", "") + extension)));

    } catch (FontFormatException | IOException e) {
        logger.logError("An error occured while trying to register the font: " + CAVIAR_FONT_NAME + extension);

    }
    NAME_FONT = new Font(CAVIAR_FONT_NAME, Font.BOLD, 18);
    SMALL_NAME_FONT = new Font(CAVIAR_FONT_NAME, Font.PLAIN, 15);
    STATS_FONT = new Font(CAVIAR_FONT_NAME, Font.PLAIN, 18);
}
项目:incubator-netbeans    文件:OutlineViewDropSupport.java   
/** Activates or deactivates Drag support on asociated JTree
* component
* @param active true if the support should be active, false
* otherwise
*/
public void activate(boolean active) {
    if (this.active == active) {
        return;
    }

    this.active = active;
    if (GraphicsEnvironment.isHeadless()) {
        return;
    }
    getDropTarget().setActive(active);
    //we want to support drop into scroll pane's free area and treat it as 'root node drop'
    if( null == outerDropTarget ) {
        outerDropTarget = new DropTarget(view.getViewport(), view.getAllowedDropActions(), this, false);
    }
    outerDropTarget.setActive(active);
}
项目:openjdk-jdk10    文件:VolatileImageBug.java   
public static void main(String[] args) {

        boolean iaeThrown = false;
        GraphicsEnvironment ge = GraphicsEnvironment.
                                      getLocalGraphicsEnvironment();
        GraphicsConfiguration gc = ge.getDefaultScreenDevice().
                                           getDefaultConfiguration();
        try {
            VolatileImage volatileImage = gc.createCompatibleVolatileImage(0, 0);
        } catch (IllegalArgumentException iae) {
            iaeThrown = true;
        }
        if (!iaeThrown) {
            throw new RuntimeException ("IllegalArgumentException not thrown " +
                                        "for createCompatibleVolatileImage(0,0)");
        }
    }
项目:openjdk-jdk10    文件:MultiScreenRobotPosition.java   
public static void main(String[] args) throws Exception {
    GraphicsDevice[] sds = GraphicsEnvironment.getLocalGraphicsEnvironment()
                                              .getScreenDevices();
    for (final GraphicsDevice gd : sds) {
        fail = true;
        Robot robot = new Robot(gd);
        robot.setAutoDelay(100);
        robot.setAutoWaitForIdle(true);

        Frame frame = new Frame(gd.getDefaultConfiguration());
        frame.setUndecorated(true);
        frame.setSize(400, 400);
        frame.setVisible(true);
        robot.waitForIdle();

        frame.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                System.out.println("e = " + e);
                fail = false;
            }
        });

        Rectangle bounds = frame.getBounds();
        robot.mouseMove(bounds.x + bounds.width / 2,
                        bounds.y + bounds.height / 2);
        robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK);
        frame.dispose();
        if (fail) {
            System.err.println("Frame bounds = " + bounds);
            throw new RuntimeException("Click in the wrong location");
        }
    }
}
项目:openjdk-jdk10    文件:IsToolkitUseTheMainScreen.java   
private static void testHeadful() {
    GraphicsEnvironment ge
            = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsConfiguration gc
            = ge.getDefaultScreenDevice().getDefaultConfiguration();
    Dimension gcSize = gc.getBounds().getSize();
    ColorModel gcCM = gc.getColorModel();

    Dimension toolkitSize = Toolkit.getDefaultToolkit().getScreenSize();
    ColorModel toolkitCM = Toolkit.getDefaultToolkit().getColorModel();

    if (!gcSize.equals(toolkitSize)) {
        System.err.println("Toolkit size = " + toolkitSize);
        System.err.println("GraphicsConfiguration size = " + gcSize);
        throw new RuntimeException("Incorrect size");
    }
    if (!gcCM.equals(toolkitCM)) {
        System.err.println("Toolkit color model = " + toolkitCM);
        System.err.println("GraphicsConfiguration color model = " + gcCM);
        throw new RuntimeException("Incorrect color model");
    }
}
项目:openjdk-jdk10    文件:XlibUtil.java   
/**
 * Xinerama-aware version of XlibWrapper.RootWindow method.
 */
public static long getRootWindow(int screenNumber)
{
    XToolkit.awtLock();
    try
    {
        X11GraphicsEnvironment x11ge = (X11GraphicsEnvironment)
            GraphicsEnvironment.getLocalGraphicsEnvironment();
        if (x11ge.runningXinerama())
        {
            // all the Xinerama windows share the same root window
            return XlibWrapper.RootWindow(XToolkit.getDisplay(), 0);
        }
        else
        {
            return XlibWrapper.RootWindow(XToolkit.getDisplay(), screenNumber);
        }
    }
    finally
    {
        XToolkit.awtUnlock();
    }
}
项目:jdk8u-jdk    文件:Desktop.java   
/**
 * Returns the <code>Desktop</code> instance of the current
 * browser context.  On some platforms the Desktop API may not be
 * supported; use the {@link #isDesktopSupported} method to
 * determine if the current desktop is supported.
 * @return the Desktop instance of the current browser context
 * @throws HeadlessException if {@link
 * GraphicsEnvironment#isHeadless()} returns {@code true}
 * @throws UnsupportedOperationException if this class is not
 * supported on the current platform
 * @see #isDesktopSupported()
 * @see java.awt.GraphicsEnvironment#isHeadless
 */
public static synchronized Desktop getDesktop(){
    if (GraphicsEnvironment.isHeadless()) throw new HeadlessException();
    if (!Desktop.isDesktopSupported()) {
        throw new UnsupportedOperationException("Desktop API is not " +
                                                "supported on the current platform");
    }

    sun.awt.AppContext context = sun.awt.AppContext.getAppContext();
    Desktop desktop = (Desktop)context.get(Desktop.class);

    if (desktop == null) {
        desktop = new Desktop();
        context.put(Desktop.class, desktop);
    }

    return desktop;
}
项目:openjdk-jdk10    文件:DisplayChangeVITest.java   
public static void main(String[] args) throws Exception {
    DisplayChangeVITest test = new DisplayChangeVITest();
    GraphicsDevice gd =
        GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice();
    if (gd.isFullScreenSupported()) {
        gd.setFullScreenWindow(test);
        Thread t = new Thread(test);
        t.run();
        synchronized (lock) {
            while (!done) {
                try {
                    lock.wait(50);
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
                }
            }
        }
        System.err.println("Test Passed.");
    } else {
        System.err.println("Full screen not supported. Test passed.");
    }
}
项目: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);
        }
    }
项目:Pixie    文件:Resize.java   
/**
 * Resize the window to user prefer size. In case the zoomed user preference
 * is not set, then resize the width and height to fit the max display size
 * In case the provided width and height are smaller than max allowed size
 * they will be zoomed in(maximized) to max allowed size. In case the width
 * and height are bigger than max allowed size they will be zoomed
 * out(minimized) to max allowed size
 *
 * @param width           object's width
 * @param height          object's height
 * @param userZoomedIndex user's prefer zoomed index
 */
public Resize(int width, int height, int userZoomedIndex) {
    GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    int widthSc = gd.getDisplayMode().getWidth();
    int heightSc = gd.getDisplayMode().getHeight();
    double ratioW;
    double ratioH;
    double cropRatio;

    /* did the user saved its zoomed preference? */
    if (userZoomedIndex == Integer.MAX_VALUE) {
        ratioW = (double) width / (widthSc * MAX_SCREEN_PERCENT_RESIZE);
        ratioH = (double) height / (heightSc * MAX_SCREEN_PERCENT_RESIZE);
        cropRatio = (double) width / (double) height;
    } else {
        int tmpWidth = Math.abs(width) + userZoomedIndex * Math.abs(width / ZOOMING_FACTOR);
        int tmpHeight = Math.abs(height) + userZoomedIndex * Math.abs(height / ZOOMING_FACTOR);

        ratioW = (double) width / (double) tmpWidth;
        ratioH = (double) height / (double) tmpHeight;
        cropRatio = (double) width / (double) height;
    }

    computeResizeRatios(ratioW, ratioH, cropRatio, width, height, widthSc, heightSc);
}
项目:OpenJSharp    文件:WGLSurfaceData.java   
public static WGLGraphicsConfig getGC(WComponentPeer peer) {
    if (peer != null) {
        return (WGLGraphicsConfig)peer.getGraphicsConfiguration();
    } else {
        // REMIND: this should rarely (never?) happen, but what if
        //         default config is not WGL?
        GraphicsEnvironment env =
            GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice gd = env.getDefaultScreenDevice();
        return (WGLGraphicsConfig)gd.getDefaultConfiguration();
    }
}
项目:JavaGraph    文件:Icons.java   
/** Creates a named cursor from a given file. */
static private Cursor createCursor(String name, ImageIcon icon) {
    if (GraphicsEnvironment.isHeadless()) {
        // The environtment variable DISPLAY is not set. We can't call
        // createCustomCursor from the awt toolkit because this causes
        // a java.awt.HeadlessException. In any case we don't need the
        // cursor because we are running without GUI, so we just abort.
        return null;
    } else {
        Toolkit tk = Toolkit.getDefaultToolkit();
        Image cursorImage = icon.getImage();
        return tk.createCustomCursor(cursorImage, new Point(0, 0), name);
    }
}
项目:SerialPortDemo    文件:MainFrame.java   
private void initView() {
    // 关闭程序
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    // 禁止窗口最大化
    setResizable(false);

    // 设置程序窗口居中显示
    Point p = GraphicsEnvironment.getLocalGraphicsEnvironment()
            .getCenterPoint();
    setBounds(p.x - WIDTH / 2, p.y - HEIGHT / 2, WIDTH, HEIGHT);
    this.setLayout(null);

    setTitle("串口通讯");
}
项目:openjdk-jdk10    文件:IncorrectAlphaConversionBicubic.java   
public static void main(final String[] args) {
    final GraphicsEnvironment ge =
            GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsDevice gd = ge.getDefaultScreenDevice();
    final GraphicsConfiguration gc = gd.getDefaultConfiguration();
    final VolatileImage vi =
            gc.createCompatibleVolatileImage(SIZE, SIZE, TRANSLUCENT);
    final BufferedImage bi = makeUnmanagedBI(gc, TRANSLUCENT);
    final int expected = bi.getRGB(2, 2);

    int attempt = 0;
    BufferedImage snapshot;
    while (true) {
        if (++attempt > 10) {
            throw new RuntimeException("Too many attempts: " + attempt);
        }
        vi.validate(gc);
        final Graphics2D g2d = vi.createGraphics();
        g2d.setComposite(AlphaComposite.Src);
        g2d.scale(2, 2);
        g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                             RenderingHints.VALUE_INTERPOLATION_BICUBIC);
        g2d.drawImage(bi, 0, 0, null);
        g2d.dispose();

        snapshot = vi.getSnapshot();
        if (vi.contentsLost()) {
            continue;
        }
        break;
    }
    final int actual = snapshot.getRGB(2, 2);
    if (actual != expected) {
        System.err.println("Actual: " + Integer.toHexString(actual));
        System.err.println("Expected: " + Integer.toHexString(expected));
        throw new RuntimeException("Test failed");
    }
}
项目:OpenJSharp    文件:FontPanel.java   
static Integer getDefaultLCDContrast() {
    if (defaultContrast == null) {
        GraphicsConfiguration gc =
        GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice().getDefaultConfiguration();
    Graphics2D g2d =
        (Graphics2D)(gc.createCompatibleImage(1,1).getGraphics());
    defaultContrast = (Integer)
        g2d.getRenderingHint(RenderingHints.KEY_TEXT_LCD_CONTRAST);
    }
    return defaultContrast;
}
项目:incubator-netbeans    文件:PaletteItemRegistrationProcessorTest.java   
public void testAnnotatedPackage() throws IOException {
    //missing body
    clearWorkDir();
    assertTrue("Headless run", GraphicsEnvironment.isHeadless());
    AnnotationProcessorTestUtils.makeSource(getWorkDir(), "testa.package-info",
            VALID_PACKAGE_ANNOTATION
            + "\npackage testa\n;"
            + "import org.netbeans.spi.palette.PaletteItemRegistration;\n");
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    boolean r = AnnotationProcessorTestUtils.runJavac(getWorkDir(), null, getWorkDir(), null, os);
    assertTrue("Compilation has to be successfull:\n" + os, r);
}
项目:incubator-netbeans    文件:StatusLineComponent.java   
public void hidePopup() {
        if (GraphicsEnvironment.isHeadless()) {
            return;
        }
        if (popupWindow != null) {
//            popupWindow.getContentPane().removeAll();
            popupWindow.setVisible(false);
        }
        Toolkit.getDefaultToolkit().removeAWTEventListener(hideListener);
        WindowManager.getDefault().getMainWindow().removeWindowStateListener(hideListener);
        WindowManager.getDefault().getMainWindow().removeComponentListener(hideListener);
        showingPopup = false;
    }
项目:incubator-netbeans    文件:ProjectUiModule.java   
@Override
public void restored() {
    if (!GraphicsEnvironment.isHeadless()) {
        Hacks.keepCurrentProjectNameUpdated();
    }
    BrokenProjectNotifier.getInstnace().start();
}
项目:jdk8u-jdk    文件:GLXSurfaceData.java   
public static GLXGraphicsConfig getGC(X11ComponentPeer peer) {
    if (peer != null) {
        return (GLXGraphicsConfig)peer.getGraphicsConfiguration();
    } else {
        // REMIND: this should rarely (never?) happen, but what if
        //         default config is not GLX?
        GraphicsEnvironment env =
            GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice gd = env.getDefaultScreenDevice();
        return (GLXGraphicsConfig)gd.getDefaultConfiguration();
    }
}
项目:owa-notifier    文件:Screen.java   
private void setupDimensions(boolean spanMultipleMonitors) {
    if (spanMultipleMonitors) {
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        m_width = screenSize.width;
        m_height = screenSize.height;

    } else {
        GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
        m_width = gd.getDisplayMode().getWidth();
        m_height = gd.getDisplayMode().getHeight();
    }
}
项目:incubator-netbeans    文件:PaletteItemRegistrationProcessorTest.java   
public void testActiveEditorDropAnnotatedWithInvalidResources() throws IOException {
    clearWorkDir();
    assertTrue("Headless run", GraphicsEnvironment.isHeadless());
    AnnotationProcessorTestUtils.makeSource(getWorkDir(), "test.B",
            "import org.netbeans.spi.palette.PaletteItemRegistration;\n"
            + "import org.openide.text.ActiveEditorDrop;\n;import javax.swing.text.JTextComponent;"
            + INVALIDRESOURCE_CLASS_ANNOTATION
            + "public class B implements ActiveEditorDrop {\n"
            + "     public boolean handleTransfer(JTextComponent targetComponent) {return true; }"
            + "}\n");
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    boolean r = AnnotationProcessorTestUtils.runJavac(getWorkDir(), null, getWorkDir(), null, os);
    assertFalse("Compilation has to fail:\n" + os, r);
}
项目:Luyten4Forge    文件:JFontChooser.java   
protected String[] getFontFamilies() {
    if (fontFamilyNames == null) {
        GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
        fontFamilyNames = env.getAvailableFontFamilyNames();
    }
    return fontFamilyNames;
}
项目:incubator-netbeans    文件:NbEvents.java   
private void notify(String text, boolean warn) {
    if (GraphicsEnvironment.isHeadless() || Boolean.getBoolean("netbeans.full.hack")) { // NOI18N
        // #21773: interferes with automated GUI testing.
        logger.log(Level.WARNING, "{0}\n", text);
    } else {
        // Normal - display dialog.
        new Notifier(text, warn).show();
    }
}
项目:powertext    文件:Util.java   
/**
 * Returns the screen coordinates for the monitor that contains the
 * specified point.  This is useful for setups with multiple monitors,
 * to ensure that popup windows are positioned properly.
 *
 * @param x The x-coordinate, in screen coordinates.
 * @param y The y-coordinate, in screen coordinates.
 * @return The bounds of the monitor that contains the specified point.
 */
public static Rectangle getScreenBoundsForPoint(int x, int y) {
    GraphicsEnvironment env = GraphicsEnvironment.
                                    getLocalGraphicsEnvironment();
    GraphicsDevice[] devices = env.getScreenDevices();
    for (int i=0; i<devices.length; i++) {
        GraphicsConfiguration config = devices[i].getDefaultConfiguration();
        Rectangle gcBounds = config.getBounds();
        if (gcBounds.contains(x, y)) {
            return gcBounds;
        }
    }
    // If point is outside all monitors, default to default monitor (?)
    return env.getMaximumWindowBounds();
}
项目:OpenJSharp    文件:DragSource.java   
private static Cursor load(String name) {
    if (GraphicsEnvironment.isHeadless()) {
        return null;
    }

    try {
        return (Cursor)Toolkit.getDefaultToolkit().getDesktopProperty(name);
    } catch (Exception e) {
        e.printStackTrace();

        throw new RuntimeException("failed to load system cursor: " + name + " : " + e.getMessage());
    }
}
项目:BaseClient    文件:MinecraftServer.java   
public void addServerTypeToSnooper(PlayerUsageSnooper playerSnooper)
{
    playerSnooper.addStatToSnooper("singleplayer", Boolean.valueOf(this.isSinglePlayer()));
    playerSnooper.addStatToSnooper("server_brand", this.getServerModName());
    playerSnooper.addStatToSnooper("gui_supported", GraphicsEnvironment.isHeadless() ? "headless" : "supported");
    playerSnooper.addStatToSnooper("dedicated", Boolean.valueOf(this.isDedicatedServer()));
}
项目:incubator-netbeans    文件:DragWindow.java   
private BufferedImage createTabImage() {
    GraphicsConfiguration config = GraphicsEnvironment.getLocalGraphicsEnvironment()
                .getDefaultScreenDevice().getDefaultConfiguration();

    //the tab rectangle must be painted by top-level window otherwise the transparent 
    //button icons will be messed up
    Window parentWindow = SwingUtilities.getWindowAncestor(container.getComponent());
    Rectangle rect = SwingUtilities.convertRectangle(container.getComponent(), tabRectangle, parentWindow);
    BufferedImage res = config.createCompatibleImage(tabRectangle.width, tabRectangle.height);
    Graphics2D g = res.createGraphics();
    g.translate(-rect.x, -rect.y);
    g.setClip(rect);
    parentWindow.paint(g);
    return res;
}
项目:sbc-qsystem    文件:ABoardFX.java   
/**
 */
public void showBoard() {
    if (0 != cfg.getInt("device", 0)) {

        GraphicsDevice[] screenDevices = GraphicsEnvironment.getLocalGraphicsEnvironment()
            .getScreenDevices();
        int i = 1;
        for (GraphicsDevice graphicsDevice : screenDevices) {
            System.out.println(
                "graphicsDevice = " + graphicsDevice.getIDstring() + " " + graphicsDevice
                    .toString()
                    + "\nРазрешение экрана " + graphicsDevice.getDefaultConfiguration()
                    .getBounds().height + "x" + graphicsDevice.getDefaultConfiguration()
                    .getBounds().width
                    + "\nГлубина цвета " + graphicsDevice.getDisplayMode().getBitDepth()
                    + "\nЧастота " + graphicsDevice.getDisplayMode().getRefreshRate()
                    + "\nНачало координат " + graphicsDevice.getDefaultConfiguration()
                    .getBounds().x
                    + "-" + graphicsDevice.getDefaultConfiguration().getBounds().y);
            if (i == cfg.getInt("device")) {
                win_x = graphicsDevice.getDefaultConfiguration().getBounds().x;
                win_y = graphicsDevice.getDefaultConfiguration().getBounds().y;
                win_w = graphicsDevice.getDefaultConfiguration().getBounds().width;
                win_h = graphicsDevice.getDefaultConfiguration().getBounds().height;
            }
            i++;
        }

        SwingUtilities.invokeLater(() -> {
            initAndShowGUI();
        });
    }
}
项目:jdk8u-jdk    文件:SurfaceDataProxy.java   
/**
 * This method should be called from subclasses which create
 * cached SurfaceData objects that depend on the current
 * properties of the display.
 */
protected void activateDisplayListener() {
    GraphicsEnvironment ge =
        GraphicsEnvironment.getLocalGraphicsEnvironment();
    // We could have a HeadlessGE at this point, so double-check before
    // assuming anything.
    // Also, no point in listening to display change events if
    // the image is never going to be accelerated.
    if (ge instanceof SunGraphicsEnvironment) {
        ((SunGraphicsEnvironment)ge).addDisplayChangedListener(this);
    }
}
项目:incubator-netbeans    文件:PropertyPanel.java   
/** The constructor all the other constructors call */
private PropertyPanel(Node.Property p, int preferences, PropertyModel mdl) {
    if (p == null) {
        prop = ModelProperty.toProperty(mdl);
    } else {
        prop = p;
    }

    this.preferences = preferences;
    initializing = true;
    setModel(mdl);
    initializing = false;
    setOpaque(true);

    if (!GraphicsEnvironment.isHeadless()) {
        //for debugging, allow CTRL-. to dump the state to stderr
        getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
            KeyStroke.getKeyStroke(KeyEvent.VK_PERIOD, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), "dump"
        );
    }
    getActionMap().put(
        "dump",
        new AbstractAction() { //NOI18N
            public void actionPerformed(ActionEvent ae) {
                System.err.println(""); //NOI18N
                System.err.println(PropertyPanel.this);
                System.err.println(""); //NOI18N
            }
        }
    );

    //#44226 - Unpretty, but this allows the TreeTableView to invoke a custom editor dialog when
    //necessary - with the TTV rewrite, all cell editor infrastructure will be moved to
    //org.netbeans.modules.openide.explorer, and they will simply share editor classes.  Since that
    //involves an API change (some package private methods of PropertyEnv need to be accessible to
    //the editor classes), this will have to wait for after 4.0 - Tim
    getActionMap().put("invokeCustomEditor", new CustomEditorProxyAction()); //NOI18N

    PropertyPanelBridge.register(this, new BridgeAccessor(this));
}
项目:jdk8u-jdk    文件:WGLSurfaceData.java   
public static WGLGraphicsConfig getGC(WComponentPeer peer) {
    if (peer != null) {
        return (WGLGraphicsConfig)peer.getGraphicsConfiguration();
    } else {
        // REMIND: this should rarely (never?) happen, but what if
        //         default config is not WGL?
        GraphicsEnvironment env =
            GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice gd = env.getDefaultScreenDevice();
        return (WGLGraphicsConfig)gd.getDefaultConfiguration();
    }
}