Example usage for java.awt GraphicsEnvironment getDefaultScreenDevice

List of usage examples for java.awt GraphicsEnvironment getDefaultScreenDevice

Introduction

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

Prototype

public abstract GraphicsDevice getDefaultScreenDevice() throws HeadlessException;

Source Link

Document

Returns the default screen GraphicsDevice .

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gs = ge.getDefaultScreenDevice();

    DisplayMode[] dmodes = gs.getDisplayModes();
    for (int i = 0; i < dmodes.length; i++) {
        DisplayMode dm = dmodes[i];
        if (dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI) {
            System.out.println("DisplayMode.BIT_DEPTH_MULTI");
        }/*from  w w w .ja v a2 s. co  m*/
    }
}

From source file:Main.java

public static void main(String[] args) {
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice vc = env.getDefaultScreenDevice();
    JFrame window = new JFrame();
    JPanel comp = new JPanel();
    comp.setBackground(Color.RED);
    window.add(comp);//from   w  ww .j ava 2s. c  o  m
    window.setUndecorated(true);
    window.setResizable(false);
    vc.setFullScreenWindow(window);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gs = ge.getDefaultScreenDevice();

    DisplayMode[] dmodes = gs.getDisplayModes();
    for (int i = 0; i < dmodes.length; i++) {
        DisplayMode dm = dmodes[i];
        int screenWidth = dm.getWidth();
        int screenHeight = dm.getHeight();

        System.out.println(screenWidth);
        System.out.println(screenHeight);
    }/*  w w w  .j  a va 2 s  .  c om*/
}

From source file:Main.java

public static void main(String[] args) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice defaultScreen = ge.getDefaultScreenDevice();
    GraphicsConfiguration[] configurations = defaultScreen.getConfigurations();
    System.out.println("Default screen device: " + defaultScreen.getIDstring());
    for (int i = 0; i < configurations.length; i++) {
        System.out.println("  Configuration " + (i + 1));
        System.out.println("  " + configurations[i].getColorModel());
    }//w  ww  .j  a  v a  2  s.c o  m
}

From source file:ShowConfigurations.java

public static void main(String[] args) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice defaultScreen = ge.getDefaultScreenDevice();
    GraphicsConfiguration[] configurations = defaultScreen.getConfigurations();
    System.out.println("Default screen device: " + defaultScreen.getIDstring());
    for (int i = 0; i < configurations.length; i++) {
        System.out.println("  Configuration " + (i + 1));
        System.out.println("  " + configurations[i].getColorModel());
    }//  ww  w  .  j  a  v  a  2  s.  c  o  m
    System.exit(0);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gs = ge.getDefaultScreenDevice();

    boolean canChg = gs.isDisplayChangeSupported();
    if (canChg) {
        DisplayMode displayMode = gs.getDisplayMode();
        int screenWidth = 640;
        int screenHeight = 480;
        int bitDepth = 8;
        displayMode = new DisplayMode(screenWidth, screenHeight, bitDepth, displayMode.getRefreshRate());
        try {//from   w  w  w.j  a va2  s.c  o  m
            gs.setDisplayMode(displayMode);
        } catch (Throwable e) {
            gs.setFullScreenWindow(null);
        }
    }
}

From source file:Main.java

public static void main(String[] args) {
    String TITLE = "Full Screen Test";
    JFrame f = new JFrame(TITLE);
    JDesktopPane jdp = new JDesktopPane();

    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice dev = env.getDefaultScreenDevice();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JInternalFrame jif = new JInternalFrame(TITLE, true, true, true);
    jif.add(new JLabel(TITLE + " " + TITLE), BorderLayout.NORTH);
    jif.add(new JLabel(TITLE + " " + TITLE), BorderLayout.CENTER);
    jif.add(new JLabel(TITLE + " " + TITLE), BorderLayout.SOUTH);
    jif.pack();/*from www  .ja  va  2s  .c o  m*/
    jif.setLocation(100, 100);
    jif.setVisible(true);
    jdp.add(jif);
    f.add(jdp, BorderLayout.CENTER);
    dev.setFullScreenWindow(f);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gs = ge.getDefaultScreenDevice();

    Button btn = new Button("OK");
    btn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
            GraphicsDevice gs = ge.getDefaultScreenDevice();
            gs.setFullScreenWindow(null);
        }/*from  w w w  . j a  va  2 s.c  o m*/
    });
    Frame frame = new Frame(gs.getDefaultConfiguration());
    Window win = new Window(frame);
    win.add(btn, BorderLayout.CENTER);
    try {
        gs.setFullScreenWindow(win);
        win.validate();
    } finally {
        gs.setFullScreenWindow(null);
    }
}

From source file:Main.java

public static void main(String[] args) {
    GraphicsEnvironment graphicsEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();

    GraphicsDevice graphicsDevice = graphicsEnv.getDefaultScreenDevice();

    boolean isSupported = graphicsDevice.isWindowTranslucencySupported(PERPIXEL_TRANSPARENT);
    System.out.println("PERPIXEL_TRANSPARENT  supported: " + isSupported);

    isSupported = graphicsDevice.isWindowTranslucencySupported(TRANSLUCENT);
    System.out.println("TRANSLUCENT  supported: " + isSupported);

    isSupported = graphicsDevice.isWindowTranslucencySupported(PERPIXEL_TRANSLUCENT);
    System.out.println("PERPIXEL_TRANSLUCENT  supported: " + isSupported);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.add(new JPanel() {
        @Override/*w  ww.ja  v  a  2 s.c o  m*/
        public Dimension getPreferredSize() {
            return new Dimension(320, 240);
        }

    });
    f.pack();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice defaultScreen = ge.getDefaultScreenDevice();
    Rectangle rect = defaultScreen.getDefaultConfiguration().getBounds();
    int x = (int) rect.getMaxX() - f.getWidth();
    int y = (int) rect.getMaxY() - f.getHeight();
    f.setLocation(x, y);
    f.setVisible(true);
}