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


Java GraphicsDevice类代码示例

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


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

示例1: main

import java.awt.GraphicsDevice; //导入依赖的package包/类
public static void main(final String[] args) throws Exception {
    robot = new Robot();
    robot.setAutoDelay(100);
    robot.setAutoWaitForIdle(true);
    GraphicsEnvironment ge =
            GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] sds = ge.getScreenDevices();
    UIManager.LookAndFeelInfo[] lookAndFeelArray =
            UIManager.getInstalledLookAndFeels();
    for (UIManager.LookAndFeelInfo lookAndFeelItem : lookAndFeelArray) {
        System.setProperty(PROPERTY_NAME, "true");
        step(sds, lookAndFeelItem);
        if (lookAndFeelItem.getClassName().contains("Aqua")) {
            System.setProperty(PROPERTY_NAME, "false");
            step(sds, lookAndFeelItem);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:JComboBoxPopupLocation.java

示例2: main

import java.awt.GraphicsDevice; //导入依赖的package包/类
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.");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:DisplayChangeVITest.java

示例3: main

import java.awt.GraphicsDevice; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException, InvocationTargetException {
    SwingUtilities.invokeAndWait(() -> {
        JFrame f = new JFrame();
        f.setUndecorated(true);
        GraphicsDevice gd = f.getGraphicsConfiguration().getDevice();
        if (gd.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSLUCENT)) {
            f.setBackground(new Color(0, 0, 0, 0));
        }
        f.setSize(200, 300);
        f.setVisible(true);

        try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
        } catch (Exception e) {
            System.err.println(e);
            System.err.println("Could not set GTKLookAndFeel, skipping this test");
        } finally {
            f.dispose();
        }
    });
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:RenderBadPictureCrash.java

示例4: start

import java.awt.GraphicsDevice; //导入依赖的package包/类
@Override
public void start(final Stage stage) throws Exception {
    GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    int width = gd.getDisplayMode().getWidth();
    int height = gd.getDisplayMode().getHeight();

    Scene scene = new Scene(FXMLLoader.load(UDEDesktop.class.getResource("resources/UDEDesktopWindow.fxml")), width, height);
    scene.setFill(null);
    scene.getStylesheets().add("resources/stylesheet.css");
    stage.setScene(scene);
    // stage.initStyle(StageStyle.UNDECORATED);
    stage.initStyle(StageStyle.TRANSPARENT);
    stage.setTitle("UDEDesktop");
    stage.setMinWidth(300);
    stage.setMinHeight(300);
    stage.show();
    stage.toBack();
}
 
开发者ID:maximstewart,项目名称:UDE,代码行数:19,代码来源:UDEDesktop.java

示例5: main

import java.awt.GraphicsDevice; //导入依赖的package包/类
public static void main(final String[] args) {
    final GraphicsEnvironment lge = getLocalGraphicsEnvironment();
    final GraphicsDevice dev = lge.getDefaultScreenDevice();
    final GraphicsConfiguration config = dev.getDefaultConfiguration();

    test(config.createCompatibleImage(10, 10).getGraphics());
    test(config.createCompatibleImage(10, 10, OPAQUE).getGraphics());
    test(config.createCompatibleImage(10, 10, BITMASK).getGraphics());
    test(config.createCompatibleImage(10, 10, TRANSLUCENT).getGraphics());

    test(new BufferedImage(10, 10, TYPE_INT_ARGB).getGraphics());

    final Window frame = new Frame();
    frame.pack();
    try {
        test(frame.getGraphics());
        test(frame.createImage(10, 10).getGraphics());
    } finally {
        frame.dispose();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:SurfaceDestination.java

示例6: setVisible

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

示例7: show

import java.awt.GraphicsDevice; //导入依赖的package包/类
public void show(Point location) {
    Rectangle screenBounds = null;
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    for (GraphicsDevice device : gds) {
        GraphicsConfiguration gc = device.getDefaultConfiguration();
        screenBounds = gc.getBounds();
        if (screenBounds.contains(location)) {
            break;
        }
    }

    // showing the popup tooltip
    cp = new TooltipContentPanel(master.getTextComponent());

    Window w = SwingUtilities.windowForComponent(master.getTextComponent());
    contentWindow = new JWindow(w);
    contentWindow.add(cp);
    contentWindow.pack();
    Dimension dim = contentWindow.getSize();

    if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) {
        dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER);
    }
    if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) {
        dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER);
    }

    contentWindow.setSize(dim);

    contentWindow.setLocation(location.x, location.y - 1);  // slight visual adjustment
    contentWindow.setVisible(true);

    Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
    w.addWindowFocusListener(this);
    contentWindow.addWindowFocusListener(this);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:TooltipWindow.java

示例8: show

import java.awt.GraphicsDevice; //导入依赖的package包/类
public void show(Point location) {
    Rectangle screenBounds = null;
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    for (GraphicsDevice device : gds) {
        GraphicsConfiguration gc = device.getDefaultConfiguration();
        screenBounds = gc.getBounds();
        if (screenBounds.contains(location)) {
            break;
        }
    }

    // showing the popup tooltip
    cp = new TooltipContentPanel(master.getTextComponent());
    Window w = SwingUtilities.windowForComponent(master.getTextComponent());
    contentWindow = new JWindow(w);
    contentWindow.add(cp);
    contentWindow.pack();
    Dimension dim = contentWindow.getSize();

    if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) {
        dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER);
    }
    if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) {
        dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER);
    }

    contentWindow.setSize(dim);

    contentWindow.setLocation(location.x, location.y - 1);  // slight visual adjustment
    contentWindow.setVisible(true);
    Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
    w.addWindowFocusListener(this);
    contentWindow.addWindowFocusListener(this);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:TooltipWindow.java

示例9: setWindowAlpha

import java.awt.GraphicsDevice; //导入依赖的package包/类
@Override
public void setWindowAlpha(Window w, float alpha) {
    GraphicsConfiguration gc = w.getGraphicsConfiguration();
    GraphicsDevice gd = gc.getDevice();
    if (gc.getDevice().getFullScreenWindow() == w) {
        return;
    }
    if (!gd.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.TRANSLUCENT)) {
        return;
    }
    w.setOpacity(alpha);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:NoNativeAccessWindowSystem.java

示例10: main

import java.awt.GraphicsDevice; //导入依赖的package包/类
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");
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:MultiScreenRobotPosition.java

示例11: getScreens

import java.awt.GraphicsDevice; //导入依赖的package包/类
/**
 * Returns an array of screens that are available on the current system
 * 
 * @return
 */
public static ScreenModel[] getScreens() {

	GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
	GraphicsDevice[] gd = ge.getScreenDevices();
	ScreenModel[] models = new ScreenModel[gd.length];
	for (int i = 0; i < gd.length; i++) {
		if (gd[i].getIDstring().equals(getDefaultScreenId())) {
			models[i] = new ScreenModel(gd[i], "(" + I18n.get("settings.mainscreen") + ")", i + 1);
		} else {
			models[i] = new ScreenModel(gd[i], "", i + 1);
		}

	}

	return models;
}
 
开发者ID:michaelnetter,项目名称:dracoon-dropzone,代码行数:22,代码来源:Util.java

示例12: getScreenBoundsForPoint

import java.awt.GraphicsDevice; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:26,代码来源:TipUtil.java

示例13: hasAppleRetinaDisplay

import java.awt.GraphicsDevice; //导入依赖的package包/类
/**
 * hack from
 * https://bulenkov.com/2013/06/23/retina-support-in-oracle-jdk-1-7/ used to
 * multiply mouse coordinates by two in case of retina display; see
 * http://forum.lwjgl.org/index.php?topic=5084.0
 *
 * @return true if running on platform with retina display. Value is cached
 * in VM to avoid runtime cost penalty of multiple calls.
 */
public static boolean hasAppleRetinaDisplay() {
    if (checkedRetinaDisplay) {
        return hasRetinaDisplayTrue;
    }
    checkedRetinaDisplay = true;
    //other OS and JVM specific checks...
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    final GraphicsDevice device = env.getDefaultScreenDevice();

    try {
        Field field = device.getClass().getDeclaredField("scale");

        if (field != null) {
            field.setAccessible(true);
            Object scale = field.get(device);

            if (scale instanceof Integer && ((Integer) scale).intValue() == 2) {
                hasRetinaDisplayTrue = true;
            }
        }
    } catch (Exception ignore) {
    }
    //...
    return hasRetinaDisplayTrue;
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:35,代码来源:ChipCanvas.java

示例14: findDisplayMode

import java.awt.GraphicsDevice; //导入依赖的package包/类
/**
 * Finds a display mode that is different from the current display
 * mode and is likely to cause a display change event.
 */
private static DisplayMode findDisplayMode(GraphicsDevice gd) {
    DisplayMode dms[] = gd.getDisplayModes();
    DisplayMode currentDM = gd.getDisplayMode();
    for (DisplayMode dm : dms) {
        if (!dm.equals(currentDM) &&
             dm.getRefreshRate() == currentDM.getRefreshRate())
        {
            // different from the current dm and refresh rate is the same
            // means that something else is different => more likely to
            // cause a DM change event
            return dm;
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:DisplayModeChanger.java

示例15: getGraphicsDevice

import java.awt.GraphicsDevice; //导入依赖的package包/类
@Override
public GraphicsDevice getGraphicsDevice() {
    CGraphicsEnvironment ge = (CGraphicsEnvironment)GraphicsEnvironment.
                              getLocalGraphicsEnvironment();

    LWLightweightFramePeer peer = (LWLightweightFramePeer)getPeer();
    int scale = ((LightweightFrame)peer.getTarget()).getScaleFactor();

    Rectangle bounds = ((LightweightFrame)peer.getTarget()).getHostBounds();
    for (GraphicsDevice d : ge.getScreenDevices()) {
        if (d.getDefaultConfiguration().getBounds().intersects(bounds) &&
            ((CGraphicsDevice)d).getScaleFactor() == scale)
        {
            return d;
        }
    }
    // We shouldn't be here...
    return ge.getDefaultScreenDevice();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:CPlatformLWWindow.java


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