Example usage for java.awt GraphicsEnvironment getLocalGraphicsEnvironment

List of usage examples for java.awt GraphicsEnvironment getLocalGraphicsEnvironment

Introduction

In this page you can find the example usage for java.awt GraphicsEnvironment getLocalGraphicsEnvironment.

Prototype

public static GraphicsEnvironment getLocalGraphicsEnvironment() 

Source Link

Document

Returns the local GraphicsEnvironment .

Usage

From source file:DrawStringI18N.java

public void paint(Graphics g) {
    Graphics2D graphics2D = (Graphics2D) g;
    GraphicsEnvironment.getLocalGraphicsEnvironment();
    graphics2D.setFont(new Font("LucidaSans", Font.PLAIN, 40));
    graphics2D.drawString("\u05E9\u05DC\u05D5\u05DD \u05E2\u05D5\u05DC\u05DD", 50, 75);
}

From source file:JTextAreaI18N.java

public JTextAreaI18N() {
    GraphicsEnvironment.getLocalGraphicsEnvironment();
    JTextArea textArea = new JTextArea(davidMessage);
    textArea.setFont(new Font("LucidaSans", Font.PLAIN, 40));
    this.getContentPane().add(textArea);
    textArea.setVisible(true);/*  w  ww  . ja  v a  2s.  c  o  m*/
}

From source file:TrueTypeJokerman.java

public TrueTypeJokerman() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    ge.getAllFonts();// w w  w .  j  ava2 s  .  c o m

    Font font = new Font("Jokerman", Font.PLAIN, 35);
    JLabel textLabel = new JLabel(textMessage);
    textLabel.setFont(font);

    getContentPane().add(textLabel);
    setVisible(true);
}

From source file:Main.java

/**
 * Retrieves the bounds represents the available space on the Window's display that is not used up by things like
 * the task bar or dock./*w  ww . j a  v a  2s .c  o m*/
 *
 * @param window
 *         The window to center
 * @return Bounds of the display's available space
 */
public static Rectangle getBoundsOfAvailableDisplaySpace(Window window) {
    GraphicsConfiguration graphicsConfigToUse = window.getGraphicsConfiguration();
    // If the Window does not have a GraphicsConfiguration yet (perhaps when the Window is not set up yet) then use the default screen's GraphicsConfiguration.
    if (graphicsConfigToUse == null) {
        graphicsConfigToUse = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
                .getDefaultConfiguration();
    }
    Rectangle boundsOfEntireScreen = graphicsConfigToUse.getBounds();
    Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(graphicsConfigToUse);

    return new Rectangle(screenInsets.left, screenInsets.top,
            boundsOfEntireScreen.width - screenInsets.left - screenInsets.right,
            boundsOfEntireScreen.height - screenInsets.top - screenInsets.bottom);
}

From source file:Main.java

public Main() {
    super("TrueType Font Demonstration");

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    ge.getAllFonts();//from  w  ww  .ja  v a 2s.  com

    Font font = new Font("Jokerman", Font.PLAIN, 35);
    JLabel textLabel = new JLabel(textMessage);
    textLabel.setFont(font);

    getContentPane().add(textLabel);
    setVisible(true);
}

From source file:TrueTypeTest.java

public TrueTypeTest() {
    super("TrueType Font Demonstration");

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    ge.getAllFonts();//from w  ww  . j ava2  s.  c om

    Font font = new Font("Jokerman", Font.PLAIN, 35);
    JLabel textLabel = new JLabel(textMessage);
    textLabel.setFont(font);

    getContentPane().add(textLabel);
    show();
}

From source file:GCWrapper.java

public static void main(String[] args) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] devices = ge.getScreenDevices();
    for (int i = 0; i < devices.length; i++) {
        CapabilitiesTest tst = new CapabilitiesTest(devices[i]);
        tst.pack();//w  ww  .j a v  a2 s  .c o  m
        tst.setVisible(true);
    }
}

From source file:Main.java

/**
 * @param r//from w  w w .  java2 s  .c  o m
 *          the original rectangle
 * @param includeReservedInsets
 *          if taskbar and other windowing insets should be included in the
 *          returned area
 * @return iff there are multiple monitors the other monitor than the
 *         effective view of the monitor that the rectangle mostly coveres, or
 *         null if there is just one screen
 */
public static Rectangle getOppositeFullScreenBoundsFor(Rectangle r, boolean includeReservedInsets) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    TreeMap<Integer, Rectangle> prioMap = new TreeMap<Integer, Rectangle>();
    for (GraphicsDevice dev : ge.getScreenDevices()) {
        Rectangle bounds;
        if ((!includeReservedInsets) && dev == ge.getDefaultScreenDevice()) {
            bounds = ge.getMaximumWindowBounds();
        } else {
            bounds = dev.getDefaultConfiguration().getBounds();
        }
        Rectangle intersection = bounds.intersection(r);
        prioMap.put(intersection.width * intersection.height, bounds);
    }
    if (prioMap.size() <= 1) {
        return null;
    } else {
        return prioMap.get(prioMap.firstKey());
    }
}

From source file:Main.java

private void centerFrame() {
    Dimension windowSize = getSize();
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    Point centerPoint = ge.getCenterPoint();

    int dx = centerPoint.x - windowSize.width / 2;
    int dy = centerPoint.y - windowSize.height / 2;
    setLocation(dx, dy);/*  w w w .  j  a v a 2 s .  c  o m*/
}

From source file:Main.java

void initUI() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    int i = 1;/*from www. j a v  a2  s .  c  o m*/
    for (GraphicsDevice gd : ge.getScreenDevices()) {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.add(createLabel(String.valueOf(i)));
        frame.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
                .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "exit");
        frame.getRootPane().getActionMap().put("exit", new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.exit(0);
            }
        });
        frame.setLocation(gd.getDefaultConfiguration().getBounds().getLocation());
        frame.setUndecorated(true);
        frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH);
        frame.setVisible(true);
        gd.setFullScreenWindow(frame);
        i++;
    }
}