List of usage examples for java.awt GraphicsEnvironment getScreenDevices
public abstract GraphicsDevice[] getScreenDevices() throws HeadlessException;
From source file:org.jas.dnd.Jdk6u10TransparencyManager.java
@Override public GraphicsConfiguration getTranslucencyCapableGC() { GraphicsEnvironment localGraphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice defaultScreenDevice = localGraphicsEnvironment.getDefaultScreenDevice(); GraphicsConfiguration translucencyCapableGC = defaultScreenDevice.getDefaultConfiguration(); if (!isTranslucencyCapable(translucencyCapableGC)) { translucencyCapableGC = null;/* w w w.j a v a 2 s . co m*/ log.info("Default graphics configuration does not support translucency"); GraphicsEnvironment env = localGraphicsEnvironment; GraphicsDevice[] devices = env.getScreenDevices(); for (int i = 0; i < devices.length && translucencyCapableGC == null; i++) { GraphicsConfiguration[] configs = devices[i].getConfigurations(); for (int j = 0; j < configs.length && translucencyCapableGC == null; j++) { if (isTranslucencyCapable(configs[j])) { translucencyCapableGC = configs[j]; } } } } if (translucencyCapableGC == null) { log.warn("Translucency capable graphics configuration not found"); } return translucencyCapableGC; }
From source file:org.pentaho.reporting.libraries.designtime.swing.LibSwingUtil.java
public static boolean safeRestoreWindow(final Window frame, final Rectangle bounds) { final GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); final GraphicsDevice[] devices = graphicsEnvironment.getScreenDevices(); for (int i = 0; i < devices.length; i++) { final GraphicsDevice device = devices[i]; final Rectangle rectangle = device.getDefaultConfiguration().getBounds(); if (rectangle.contains(bounds) || rectangle.equals(bounds)) { logger.info("Found a usable screen-configuration: Restoring frame to " + bounds); frame.setBounds(bounds);/*w w w . j a v a2 s. com*/ return true; } } return false; }
From source file:org.pmedv.core.gui.ApplicationWindowAdvisorImpl.java
@Override public void postWindowCreate() { Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); Rectangle frame = win.getBounds(); ApplicationWindowConfiguration config = windowConfig.getConfig(); if (config.getX() > 0 && config.getY() > 0) { win.setLocation(config.getX(), config.getY()); } else {/* w ww . j a va 2 s . com*/ win.setLocation((screen.width - frame.width) / 2, (screen.height - frame.height) / 2); Rectangle bounds = new Rectangle(0, 0, screen.width, screen.height - 35); win.setBounds(bounds); } if (config.getHeight() > 0 && config.getWidth() > 0) { if (config.isMaximized()) win.setExtendedState(win.getExtendedState() | Frame.MAXIMIZED_BOTH); else win.setSize(config.getWidth(), config.getHeight()); } else { GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); numberOfDisplays = env.getScreenDevices().length; win.setMaximizedBounds(env.getMaximumWindowBounds()); win.setExtendedState(win.getExtendedState() | Frame.MAXIMIZED_BOTH); } // if (!config.isStatusbarVisible()) // win.getStatusBar().setVisible(false); }
From source file:org.rdv.datapanel.AbstractDataPanel.java
/** * Undock the UI component and display fullscreen. * //from w ww . j a v a 2s . com * @since 1.1 */ void maximizePanel() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] devices = ge.getScreenDevices(); for (int i = 0; i < devices.length; i++) { GraphicsDevice device = devices[i]; if (device.isFullScreenSupported() && device.getFullScreenWindow() == null) { maximized = true; dataPanelContainer.removeDataPanel(component); frame = new JFrame(getTitle()); frame.setUndecorated(true); frame.getContentPane().add(component); try { device.setFullScreenWindow(frame); } catch (InternalError e) { log.error("Failed to switch to full screen mode: " + e.getMessage() + "."); restorePanel(true); return; } frame.setVisible(true); frame.requestFocus(); return; } } log.warn("No screens available or full screen exclusive mode is unsupported on your platform."); }
From source file:org.rdv.datapanel.AbstractDataPanel.java
/** * Leave fullscreen mode and dock the UI component if addToContainer is true. * //www .j av a2 s . c o m * @param addToContainer whether to dock the UI component * @since 1.1 */ void restorePanel(boolean addToContainer) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] devices = ge.getScreenDevices(); for (int i = 0; i < devices.length; i++) { GraphicsDevice device = devices[i]; if (device.isFullScreenSupported() && device.getFullScreenWindow() == frame) { if (frame != null) { frame.setVisible(false); device.setFullScreenWindow(null); frame.getContentPane().remove(component); frame.dispose(); frame = null; } maximized = false; if (addToContainer) { dataPanelContainer.addDataPanel(component); } break; } } }
From source file:org.rdv.ui.MainPanel.java
private boolean enterFullScreenMode() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] devices = ge.getScreenDevices(); for (int i = 0; i < devices.length; i++) { GraphicsDevice device = devices[i]; if (device.isFullScreenSupported() && device.getFullScreenWindow() == null) { log.info("Switching to full screen mode."); frame.setVisible(false);/*from w w w.ja v a 2 s . c o m*/ try { device.setFullScreenWindow(frame); } catch (InternalError e) { log.error("Failed to switch to full screen exclusive mode."); e.printStackTrace(); frame.setVisible(true); return false; } frame.dispose(); frame.setUndecorated(true); frame.setVisible(true); frame.requestFocusInWindow(); return true; } } log.warn("No screens available or full screen exclusive mode is unsupported on your platform."); postError("Full screen mode is not supported on your platform."); return false; }
From source file:org.rdv.ui.MainPanel.java
private void leaveFullScreenMode() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] devices = ge.getScreenDevices(); for (int i = 0; i < devices.length; i++) { GraphicsDevice device = devices[i]; if (device.isFullScreenSupported() && device.getFullScreenWindow() == frame) { log.info("Leaving full screen mode."); frame.setVisible(false);/*from w w w. j av a2 s.c om*/ device.setFullScreenWindow(null); frame.dispose(); frame.setUndecorated(false); frame.setVisible(true); break; } } }
From source file:org.squidy.nodes.plugin.PatternPlugin.java
@Plugin.Interface public PNode getInterface() { PropertiesTable table = new PropertiesTable(); TextFieldControl control = new TextFieldControl(remoteAddress); control.addPropertyUpdateListener(new PropertyUpdateListener<String>() { public void propertyUpdate(String value) { remoteAddress = value;/* w ww .j ava 2 s . c om*/ disposeControlClient(); } }); TableEntry<TextFieldControl> entry = new TableEntry<TextFieldControl>("Remote IP", "Description", control, "", ""); table.addEntry(entry); control = new TextFieldControl(String.valueOf(remotePort)); control.addPropertyUpdateListener(new PropertyUpdateListener<String>() { public void propertyUpdate(String value) { remotePort = Integer.parseInt(value); disposeControlClient(); } }); entry = new TableEntry<TextFieldControl>("Remote Port", "Description", control, "", ""); table.addEntry(entry); control = new TextFieldControl(String.valueOf(patternWidth)); control.addPropertyUpdateListener(new PropertyUpdateListener<String>() { public void propertyUpdate(String value) { patternWidth = Integer.parseInt(value); } }); entry = new TableEntry<TextFieldControl>("Pattern Width", "Description", control, "", ""); table.addEntry(entry); control = new TextFieldControl(String.valueOf(patternHeight)); control.addPropertyUpdateListener(new PropertyUpdateListener<String>() { public void propertyUpdate(String value) { patternHeight = Integer.parseInt(value); } }); entry = new TableEntry<TextFieldControl>("Pattern Height", "Description", control, "", ""); table.addEntry(entry); control = new TextFieldControl(String.valueOf(patternColumns)); control.addPropertyUpdateListener(new PropertyUpdateListener<String>() { public void propertyUpdate(String value) { patternColumns = Integer.parseInt(value); } }); entry = new TableEntry<TextFieldControl>("Pattern Columns", "Description", control, "", ""); table.addEntry(entry); control = new TextFieldControl(String.valueOf(patternRows)); control.addPropertyUpdateListener(new PropertyUpdateListener<String>() { public void propertyUpdate(String value) { patternRows = Integer.parseInt(value); } }); entry = new TableEntry<TextFieldControl>("Pattern Rows", "Description", control, "", ""); table.addEntry(entry); GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); for (final GraphicsDevice device : graphicsEnvironment.getScreenDevices()) { CheckBoxControl control2 = new CheckBoxControl(false); control2.addPropertyUpdateListener(new PropertyUpdateListener<Boolean>() { /** * @param value */ public void propertyUpdate(Boolean value) { InetAddress address = null; try { address = InetAddress.getByName(remoteAddress); } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { if (client == null) { client = new ControlClient(address, remotePort); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } SwitchableCommand command = new PatternScreen(device.getIDstring(), patternWidth, patternHeight, patternColumns - 1, patternRows - 1); command.setState(value ? Switch.ON : Switch.OFF); client.send(command); Designer.getInstance().requestFocus(); } }); TableEntry<CheckBoxControl> entry2 = new TableEntry<CheckBoxControl>("Device " + device.getIDstring(), "Description", control2, "", ""); table.addEntry(entry2); } CheckBoxControl loadImageControl = new CheckBoxControl(false); TableEntry<CheckBoxControl> loadImage = new TableEntry<CheckBoxControl>("Load Camera Image", "Description", loadImageControl, "", ""); table.addEntry(loadImage); // panelControl.setImage("C:\\projects\\Squidy\\squidy-2.0.0\\bayer.PNG"); return table; }
From source file:org.zanata.util.TestEventForScreenshotListener.java
private Rectangle getScreenRectangle() { // http://stackoverflow.com/a/13380999/14379 Rectangle2D result = new Rectangle2D.Double(); GraphicsEnvironment localGE = GraphicsEnvironment.getLocalGraphicsEnvironment(); for (GraphicsDevice gd : localGE.getScreenDevices()) { for (GraphicsConfiguration graphicsConfiguration : gd.getConfigurations()) { Rectangle2D.union(result, graphicsConfiguration.getBounds(), result); }/*from w w w . ja v a 2 s . c o m*/ } return new Rectangle((int) result.getWidth(), (int) result.getHeight()); }
From source file:pcgen.gui2.PCGenFrame.java
/** * This checks to make sure that the given rectangle will be visible * on the current graphics environment//from w ww . ja va2 s .co m */ private boolean checkBounds(Rectangle rect) { if (rect.isEmpty()) { return false; } GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); for (GraphicsDevice device : env.getScreenDevices()) { Rectangle bounds = device.getDefaultConfiguration().getBounds(); if (bounds.contains(rect) || bounds.intersects(rect)) { return true; } } return false; }