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: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();/*  ww  w .j a  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[] args) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice screen = ge.getDefaultScreenDevice();

    if (!screen.isFullScreenSupported()) {
        System.out.println("Full screen mode not supported");
        System.exit(1);/*from w ww .j a va  2 s .c  om*/
    }

    try {
        BufferedImage loadedpic = ImageIO.read(new File("your.jpg"));
        screen.setFullScreenWindow(new Main(loadedpic));
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
}

From source file:MainClass.java

public static void main(String[] args) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice screen = ge.getDefaultScreenDevice();

    if (!screen.isFullScreenSupported()) {
        System.out.println("Full screen mode not supported");
        System.exit(1);//from   w ww  . j  av  a 2s.  c  om
    }

    try {
        BufferedImage loadedpic = ImageIO.read(new File("your.jpg"));
        screen.setFullScreenWindow(new MainClass(loadedpic));
    } catch (Exception e) {
        System.err.println(e.getMessage());
    }
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    int cp = 0;//from  ww  w .  j a  v a  2s  .c  o m
    StyledDocument doc;
    JTextPane jta = new JTextPane();
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    doc = jta.getStyledDocument();
    JScrollPane jsp = new JScrollPane(jta);
    jsp.setPreferredSize(new Dimension(400, 400));
    String[] fnt = ge.getAvailableFontFamilyNames();
    MutableAttributeSet mas = jta.getInputAttributes();
    for (int i = 0; i < fnt.length; i++) {
        StyleConstants.setBold(mas, false);
        StyleConstants.setItalic(mas, false);
        StyleConstants.setFontFamily(mas, fnt[i]);
        StyleConstants.setFontSize(mas, 16);

        doc.insertString(cp, fnt[i] + "\n", mas);

        StyleConstants.setBold(mas, true);
        doc.insertString(cp, fnt[i] + "bold \n", mas);
        StyleConstants.setItalic(mas, true);

        doc.insertString(cp, fnt[i] + "bold and italic\n", mas);
        StyleConstants.setBold(mas, false);
        doc.insertString(cp, fnt[i] + "italic\n", mas);
    }
    JFrame frm = new JFrame();
    frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frm.setLayout(new BorderLayout());
    frm.add(jsp, BorderLayout.CENTER);
    frm.setLocation(100, 100);
    frm.pack();
    frm.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.add(new JPanel() {
        @Override/*from   w  ww . j  a  v  a2  s.c  om*/
        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);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    device.setFullScreenWindow(frame);/*  ww w  . j a va2s  .  com*/
    device.setDisplayMode(new DisplayMode(800, 600, 32, 60));

    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowIconified(WindowEvent we) {
            if (programmatic) {
                programmatic = false;
                frame.setState(JFrame.NORMAL);
            }
        }
    });

    JButton btn = new JButton();
    btn.setText("Btn");
    final JPanel panel = new JPanel();

    panel.add(btn);
    frame.add(panel);

    btn.addActionListener(e -> {
        programmatic = true;
        JOptionPane.showMessageDialog(panel, "Sample");
    });
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.add(new JPanel() {
        @Override//from   w  ww  .ja  va2 s . com
        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 = 0;
    f.setLocation(x, y);
    f.setVisible(true);

}

From source file:Main.java

public static void main(String[] args) throws IOException {
    BufferedImage original = ImageIO.read(new URL("http://www.java2s.com/style/download.png"));

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    GraphicsConfiguration gc = gd.getDefaultConfiguration();

    BufferedImage rotated1 = create(original, -Math.PI / 2, gc);
    BufferedImage rotated2 = create(original, +Math.PI / 4, gc);
    BufferedImage rotated3 = create(original, Math.PI, gc);

    JPanel cp = new JPanel();
    cp.add(new JLabel(new ImageIcon(original)));
    cp.add(new JLabel(new ImageIcon(rotated1)));
    cp.add(new JLabel(new ImageIcon(rotated2)));
    cp.add(new JLabel(new ImageIcon(rotated3)));

    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setContentPane(cp);/*from www .j  a va 2  s . c  om*/
    f.pack();
    f.setVisible(true);

}

From source file:GuiScreens.java

public static void main(String[] args) {
    Rectangle virtualBounds = new Rectangle();
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gs = ge.getScreenDevices();
    JFrame frame[][] = new JFrame[gs.length][];
    for (int j = 0; j < gs.length; j++) {
        GraphicsDevice gd = gs[j];
        System.out.println("Device " + j + ": " + gd);
        GraphicsConfiguration[] gc = gd.getConfigurations();
        frame[j] = new JFrame[gc.length];

        for (int i = 0; i < gc.length; i++) {
            System.out.println("  Configuration " + i + ": " + gc[i]);
            System.out.println("    Bounds: " + gc[i].getBounds());
            virtualBounds = virtualBounds.union(gc[i].getBounds());
            frame[j][i] = new JFrame("Config: " + i, gc[i]);
            frame[j][i].setBounds(50, 50, 400, 100);
            frame[j][i].setLocation((int) gc[i].getBounds().getX() + 50, (int) gc[i].getBounds().getY() + 50);
            frame[j][i].getContentPane().add(new JTextArea("Config:\n" + gc[i]));
            frame[j][i].setVisible(true);
        }/* w  w w . jav  a 2s  .c  om*/
        System.out.println("Overall bounds: " + virtualBounds);
    }
}

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));
        GraphicsConfiguration c = configurations[i];
        System.out.println("  " + c.getColorModel());
        System.out.println("  " + c.getBounds());
        System.out.println("  " + c.getBufferCapabilities());
        System.out.println("  " + c.getDefaultTransform());
        System.out.println("  " + c.getDevice());
    }//w w  w .ja  va2s .c  o m
}