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