List of usage examples for java.awt GraphicsEnvironment getLocalGraphicsEnvironment
public static GraphicsEnvironment getLocalGraphicsEnvironment()
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(new JLabel("Hit Escape to exit full screen", JLabel.CENTER), BorderLayout.CENTER); frame.setSize(300, 300);//from w ww. j av a 2 s.c o m KeyStroke escapeKeyStroke = KeyStroke.getKeyStroke("ESCAPE"); Action escapeAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .setFullScreenWindow(null); } }; frame.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escapeKeyStroke, "ESCAPE"); frame.getRootPane().getActionMap().put("ESCAPE", escapeAction); GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(frame); }
From source file:ListFonts.java
public static void main(String[] args) { String[] fontNames = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); for (String fontName : fontNames) System.out.println(fontName); }
From source file:Main.java
public static void main(String[] args) { Point p1 = null;/*from w w w.j a v a 2s.c om*/ Point p2 = null; for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) { if (p1 == null) { p1 = gd.getDefaultConfiguration().getBounds().getLocation(); } else if (p2 == null) { p2 = gd.getDefaultConfiguration().getBounds().getLocation(); } } if (p2 == null) { p2 = p1; } createFrameAtLocation(p1); createFrameAtLocation(p2); }
From source file:FullScreen.java
public static void main(String args[]) { GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice graphicsDevice = graphicsEnvironment.getDefaultScreenDevice(); DisplayMode originalDisplayMode = graphicsDevice.getDisplayMode(); try {//from www . j a v a2 s . c o m Frame frame = new Frame(); frame.setUndecorated(true); frame.setIgnoreRepaint(true); graphicsDevice.setFullScreenWindow(frame); if (graphicsDevice.isDisplayChangeSupported()) { graphicsDevice.setDisplayMode(getBestDisplayMode(graphicsDevice)); } frame.createBufferStrategy(2); // 2 buffers Rectangle bounds = frame.getBounds(); BufferStrategy bufferStrategy = frame.getBufferStrategy(); while (!done()) { Graphics g = null; try { g = bufferStrategy.getDrawGraphics(); if ((counter <= 2)) { // 2 buffers g.setColor(Color.CYAN); g.fillRect(0, 0, bounds.width, bounds.height); } g.setColor(Color.RED); // redraw prior line, too, since 2 buffers if (counter != 1) { g.drawLine(counter - 1, (counter - 1) * 5, bounds.width, bounds.height); } g.drawLine(counter, counter * 5, bounds.width, bounds.height); bufferStrategy.show(); } finally { if (g != null) { g.dispose(); } } try { Thread.sleep(250); } catch (InterruptedException ignored) { } } } finally { graphicsDevice.setDisplayMode(originalDisplayMode); graphicsDevice.setFullScreenWindow(null); } System.exit(0); }
From source file:br.com.ant.system.app.AntSystemApp.java
public static void main(String[] args) { try {/*from w w w . j a v a 2 s .co m*/ if (SystemUtils.IS_OS_WINDOWS) { UIManager.setLookAndFeel(WindowsClassicLookAndFeel.class.getName()); } else { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } ColoniaFormigasView frame = new ColoniaFormigasView(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] devices = env.getScreenDevices(); DisplayMode mode = devices[0].getDisplayMode(); int height = mode.getHeight(); int width = mode.getWidth(); frame.setSize(width, height - 30); frame.setVisible(true); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:TextBouncer.java
public static void main(String[] args) { String s = "Java Source and Support"; final int size = 64; if (args.length > 0) s = args[0];// ww w . ja v a2 s . c o m Panel controls = new Panel(); final Choice choice = new Choice(); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font[] allFonts = ge.getAllFonts(); for (int i = 0; i < allFonts.length; i++) choice.addItem(allFonts[i].getName()); Font defaultFont = new Font(allFonts[0].getName(), Font.PLAIN, size); final TextBouncer bouncer = new TextBouncer(s, defaultFont); Frame f = new AnimationFrame(bouncer); f.setFont(new Font("Serif", Font.PLAIN, 12)); controls.add(bouncer.createCheckbox("Antialiasing", TextBouncer.ANTIALIASING)); controls.add(bouncer.createCheckbox("Gradient", TextBouncer.GRADIENT)); controls.add(bouncer.createCheckbox("Shear", TextBouncer.SHEAR)); controls.add(bouncer.createCheckbox("Rotate", TextBouncer.ROTATE)); controls.add(bouncer.createCheckbox("Axes", TextBouncer.AXES)); Panel fontControls = new Panel(); choice.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ie) { Font font = new Font(choice.getSelectedItem(), Font.PLAIN, size); bouncer.setFont(font); } }); fontControls.add(choice); Panel allControls = new Panel(new GridLayout(2, 1)); allControls.add(controls); allControls.add(fontControls); f.add(allControls, BorderLayout.NORTH); f.setSize(300, 300); f.setVisible(true); }
From source file:RobotTest.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { // make frame with a button panel ButtonFrame frame = new ButtonFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true);//from ww w . j a v a2 s. c o m // attach a robot to the screen device GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice screen = environment.getDefaultScreenDevice(); try { Robot robot = new Robot(screen); runTest(robot); } catch (AWTException e) { e.printStackTrace(); } } }); }
From source file:io.lonelyrobot.empires.client.core.MainClientLauncher.java
public static void main(String[] args) { LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration(); cfg.title = Values.SUPERTITLE + " - " + Values.VERSION_NUMBER; final Options gameOptions = new Options(); // gameOptions.addOption("fullscreen", false, "Launch as fullscreen"); if (gameOptions.hasOption("fullscreen")) { System.out.println("Attempting to launch as fullscreen Application. This is experimental as of 1.3+"); GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); cfg.width = gd.getDisplayMode().getWidth(); cfg.height = gd.getDisplayMode().getHeight(); cfg.fullscreen = true;//from w w w . ja v a 2s . co m Values.NEW_WIDTH = cfg.width; Values.NEW_HEIGHT = cfg.height; } else { cfg.fullscreen = false; cfg.width = Values.OLD_WIDTH; cfg.height = Values.OLD_HEIGHT; } cfg.useGL30 = true; cfg.resizable = false; cfg.initialBackgroundColor = Color.BLACK; new LwjglApplication(GameCore.getInstance(), cfg); }
From source file:misc.TranslucentWindowDemo.java
public static void main(String[] args) { // Determine if the GraphicsDevice supports translucency. GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); //If translucent windows aren't supported, exit. if (!gd.isWindowTranslucencySupported(TRANSLUCENT)) { System.err.println("Translucency is not supported"); System.exit(0);/* w w w. j a v a 2 s. c om*/ } JFrame.setDefaultLookAndFeelDecorated(true); // Create the GUI on the event-dispatching thread SwingUtilities.invokeLater(new Runnable() { @Override public void run() { TranslucentWindowDemo tw = new TranslucentWindowDemo(); // Set the window to 55% opaque (45% translucent). tw.setOpacity(0.55f); // Display the window. tw.setVisible(true); } }); }
From source file:misc.ShapedWindowDemo.java
public static void main(String[] args) { // Determine what the GraphicsDevice can support. GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); final boolean isTranslucencySupported = gd.isWindowTranslucencySupported(TRANSLUCENT); //If shaped windows aren't supported, exit. if (!gd.isWindowTranslucencySupported(PERPIXEL_TRANSPARENT)) { System.err.println("Shaped windows are not supported"); System.exit(0);//www .j a va 2 s .c o m } //If translucent windows aren't supported, //create an opaque window. if (!isTranslucencySupported) { System.out.println("Translucency is not supported, creating an opaque window"); } // Create the GUI on the event-dispatching thread SwingUtilities.invokeLater(new Runnable() { @Override public void run() { ShapedWindowDemo sw = new ShapedWindowDemo(); // Set the window to 70% translucency, if supported. if (isTranslucencySupported) { sw.setOpacity(0.7f); } // Display the window. sw.setVisible(true); } }); }