List of usage examples for java.awt GraphicsEnvironment getMaximumWindowBounds
public Rectangle getMaximumWindowBounds() throws HeadlessException
From source file:com.lfv.lanzius.server.WorkspaceView.java
/** * Set up the ISA chart/*w ww . j av a 2 s . c om*/ * @param selectionList selected terminals */ public void initIsaChart() { if (isaChart == null) { // Create a chart: isaChart = new ZoomableChart(); } if (isaFrame == null) { // Make it visible: // Create a frame. isaFrame = new JFrame("ISADynamicChart"); // add the chart to the frame: isaChart.getAxisY().setPaintGrid(true); isaChart.setGridColor(Color.LIGHT_GRAY); isaChart.getAxisX().setRangePolicy(new RangePolicyHighestValues()); if (server.getIsaExtendedMode()) { isaChart.getAxisY().setRangePolicy(new RangePolicyFixedViewport(new Range(0, 9))); } else { isaChart.getAxisY().setRangePolicy(new RangePolicyFixedViewport(new Range(0, 5))); } isaChart.getAxisX().setAxisTitle(new AxisTitle("Time (minutes)")); isaChart.getAxisY().setAxisTitle(new AxisTitle("ISA value")); isaFrame.getContentPane().add(isaChart); // Add popup menues to the pane isaFrame.getContentPane().add(new ChartPanel(isaChart)); if (server.getIsaExtendedMode()) { isaFrame.setSize(1000, 300); } else { isaFrame.setSize(1000, 205); } isaFrame.setAlwaysOnTop(true); GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle rect = graphicsEnvironment.getMaximumWindowBounds(); isaFrame.setLocation(rect.width - 1020, rect.height - 370); // Enable the termination button [cross on the upper right edge]: isaFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { panel.updateButtons(false, null); } }); server.setIsaStartTime(System.currentTimeMillis()); } isaFrame.setVisible(true); }
From source file:co.com.soinsoftware.hotelero.view.JFRoom.java
private void setMaximized() { final GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); this.setMaximizedBounds(env.getMaximumWindowBounds()); this.setExtendedState(this.getExtendedState() | JFrame.MAXIMIZED_BOTH); }
From source file:com.lfv.lanzius.application.Controller.java
public synchronized void settingsDialogOpen() { if (state != CLIENT_STATE_STARTED) return;/* www . ja v a 2 s . c o m*/ // This button is also used to stop the auto tester if (autoTesterEnabled) { autoTester.stopTester(); JOptionPane.showMessageDialog(view, "The auto tester has been stopped! The settings dialog\n" + "is unaccessible when the auto tester is enabled!", "Auto tester", JOptionPane.INFORMATION_MESSAGE); return; } if (settingsDialog == null) { boolean full = properties.getUserInterfaceStyle().equalsIgnoreCase("full"); if (!full) JDialog.setDefaultLookAndFeelDecorated(true); settingsDialog = new JDialog(view, "Settings", false); settingsDialog.setContentPane(new SettingsPane(this)); if (full) { settingsDialog.setResizable(false); settingsDialog.setUndecorated(true); Rectangle rect = view.getBounds(); rect.x += rect.width * 0.1; rect.y += rect.height * 0.1; rect.width *= 0.8; rect.height *= 0.8; settingsDialog.setBounds(rect); // Hide mouse cursor if stated in the properties file if (properties.isMouseCursorHidden()) settingsDialog.setCursor(InvisibleCursor.getCursor()); } else { GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle rect = graphicsEnvironment.getMaximumWindowBounds(); rect.x += rect.width * 0.25; rect.y += rect.height * 0.25; rect.width *= 0.5; rect.height *= 0.5; settingsDialog.setBounds(rect); settingsDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); settingsDialog.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { settingsDialogClose(); } }); } settingsDialog.setVisible(true); } }
From source file:com.freedomotic.jfrontend.MainWindow.java
private void setFullscreenMode() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); if (gd.isFullScreenSupported()) { frameMap.setVisible(false);//from w w w .jav a2 s . c o m menuBar.setVisible(false); frameMap.dispose(); frameClient.setVisible(false); frameClient.dispose(); desktopPane.removeAll(); desktopPane.moveToBack(this); setVisible(false); dispose(); setUndecorated(true); setResizable(false); setLayout(new BorderLayout()); drawer = master.createRenderer(drawer.getCurrEnv()); if (drawer != null) { setDrawer(drawer); } else { LOG.error( "Unable to create a drawer to render the environment on the desktop frontend in fullscreen mode"); } add(drawer); Rectangle maximumWindowBounds = ge.getMaximumWindowBounds(); setBounds(maximumWindowBounds); drawer.setVisible(true); this.setVisible(true); gd.setFullScreenWindow(this); isFullscreen = true; Callout callout = new Callout(this.getClass().getCanonicalName(), "info", i18n.msg("esc_to_exit_fullscreen"), 100, 100, 0, 5000); drawer.createCallout(callout); } }
From source file:com.lfv.lanzius.application.Controller.java
/** * Open the ISA dialog (if the radio has been silent for at least 2 seconds) * @return true if the dialog was opened *//*from w w w . j ava 2s . com*/ public boolean isaDialogOpen(int isaNumChoices, boolean isaExtendedMode, String isakeytext[]) { final int radioSilentLimit = 500; // Do not show ISA dialog until at least half a second of silence if (view == null) return true; // This might happen if ISA request when terminal is starting up, don't open ISA dialog if (isaDialog == null) { // Is radio or phone active? boolean codecActive = (radioEncoding || radioDecoding || phoneActive); // Wait for 2 seconds of radio silence if (codecActive || (System.currentTimeMillis() - radioIdleTime) < radioSilentLimit) { // Ignore ISA request if too busy return false; } boolean full = properties.getUserInterfaceStyle().equalsIgnoreCase("full"); if (!full) JDialog.setDefaultLookAndFeelDecorated(true); isaDialog = new JDialog(view, "Workload", false); isaDialog.setContentPane( new ISAPane(Controller.getInstance(), isaNumChoices, isaExtendedMode, isakeytext)); if (full) { isaDialog.setResizable(false); isaDialog.setUndecorated(true); Rectangle rect = view.getBounds(); if (isaExtendedMode) { rect.x += rect.width * 0.3; rect.y += rect.height * 0.3; rect.width *= 0.4; rect.height *= 0.5; } else { rect.x += rect.width * 0.2; rect.y += rect.height * 0.4; rect.width *= 0.6; rect.height *= 0.15; } isaDialog.setBounds(rect); // Hide mouse cursor if stated in the properties file if (properties.isMouseCursorHidden()) isaDialog.setCursor(InvisibleCursor.getCursor()); } else { GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle rect = graphicsEnvironment.getMaximumWindowBounds(); if (isaExtendedMode) { rect.x = (int) (rect.width - (rect.width * 0.2)); rect.y = (int) (rect.height - (rect.height * 0.25)); rect.width *= 0.2; rect.height *= 0.25; } else { rect.x = (int) (rect.width - (rect.width * 0.3)); rect.y = (int) (rect.height - (rect.height * 0.1)); rect.width *= 0.3; rect.height *= 0.1; } isaDialog.setBounds(rect); isaDialog.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { isaValueChosen(0); } }); } isaDialog.setVisible(true); isaReqStartTime = System.currentTimeMillis(); clipNotify.playOnce(); } return true; }
From source file:com.lfv.lanzius.server.LanziusServer.java
public void init() { log.info(Config.VERSION + "\n"); docVersion = 0;//from w w w .j ava 2s . co m frame = new JFrame(Config.TITLE + " - Server Control Panel"); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { actionPerformed(new ActionEvent(itemExit, 0, null)); } }); // Create graphical terminal view panel = new WorkspacePanel(this); frame.getContentPane().add(panel); // Create a menu bar JMenuBar menuBar = new JMenuBar(); // FILE JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); // Load configuration itemLoadConfig = new JMenuItem("Load configuration..."); itemLoadConfig.addActionListener(this); fileMenu.add(itemLoadConfig); // Load terminal setup itemLoadExercise = new JMenuItem("Load exercise..."); itemLoadExercise.addActionListener(this); fileMenu.add(itemLoadExercise); fileMenu.addSeparator(); // Exit itemExit = new JMenuItem("Exit"); itemExit.addActionListener(this); fileMenu.add(itemExit); menuBar.add(fileMenu); // SERVER JMenu serverMenu = new JMenu("Server"); serverMenu.setMnemonic(KeyEvent.VK_S); // Start itemServerStart = new JMenuItem("Start"); itemServerStart.addActionListener(this); serverMenu.add(itemServerStart); // Stop itemServerStop = new JMenuItem("Stop"); itemServerStop.addActionListener(this); serverMenu.add(itemServerStop); // Restart itemServerRestart = new JMenuItem("Restart"); itemServerRestart.addActionListener(this); itemServerRestart.setEnabled(false); serverMenu.add(itemServerRestart); // Monitor network connection itemServerMonitor = new JCheckBoxMenuItem("Monitor network"); itemServerMonitor.addActionListener(this); itemServerMonitor.setState(false); serverMenu.add(itemServerMonitor); menuBar.add(serverMenu); // TERMINAL JMenu terminalMenu = new JMenu("Terminal"); terminalMenu.setMnemonic(KeyEvent.VK_T); itemTerminalLink = new JMenuItem("Link..."); itemTerminalLink.addActionListener(this); terminalMenu.add(itemTerminalLink); itemTerminalUnlink = new JMenuItem("Unlink..."); itemTerminalUnlink.addActionListener(this); terminalMenu.add(itemTerminalUnlink); itemTerminalUnlinkAll = new JMenuItem("Unlink All"); itemTerminalUnlinkAll.addActionListener(this); terminalMenu.add(itemTerminalUnlinkAll); itemTerminalSwap = new JMenuItem("Swap..."); itemTerminalSwap.addActionListener(this); terminalMenu.add(itemTerminalSwap); menuBar.add(terminalMenu); // GROUP JMenu groupMenu = new JMenu("Group"); groupMenu.setMnemonic(KeyEvent.VK_G); itemGroupStart = new JMenuItem("Start..."); itemGroupStart.addActionListener(this); groupMenu.add(itemGroupStart); itemGroupPause = new JMenuItem("Pause..."); itemGroupPause.addActionListener(this); groupMenu.add(itemGroupPause); itemGroupStop = new JMenuItem("Stop..."); itemGroupStop.addActionListener(this); groupMenu.add(itemGroupStop); menuBar.add(groupMenu); frame.setJMenuBar(menuBar); GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle maximumWindowBounds = graphicsEnvironment.getMaximumWindowBounds(); if (Config.SERVER_SIZE_FULLSCREEN) { maximumWindowBounds.setLocation(0, 0); maximumWindowBounds.setSize(Toolkit.getDefaultToolkit().getScreenSize()); frame.setResizable(false); frame.setUndecorated(true); } else if (Config.SERVER_SIZE_100P_WINDOW) { // Fixes a bug in linux using gnome. With the line below the upper and // lower bars are respected maximumWindowBounds.height -= 1; } else if (Config.SERVER_SIZE_75P_WINDOW) { maximumWindowBounds.width *= 0.75; maximumWindowBounds.height *= 0.75; } else if (Config.SERVER_SIZE_50P_WINDOW) { maximumWindowBounds.width /= 2; maximumWindowBounds.height /= 2; } frame.setBounds(maximumWindowBounds); frame.setVisible(true); log.info("Starting control panel"); // Autostart for debugging if (Config.SERVER_AUTOLOAD_CONFIGURATION != null) actionPerformed(new ActionEvent(itemLoadConfig, 0, null)); if (Config.SERVER_AUTOSTART_SERVER) actionPerformed(new ActionEvent(itemServerStart, 0, null)); if (Config.SERVER_AUTOLOAD_EXERCISE != null) actionPerformed(new ActionEvent(itemLoadExercise, 0, null)); if (Config.SERVER_AUTOSTART_GROUP > 0) actionPerformed(new ActionEvent(itemGroupStart, 0, null)); try { // Read the property files serverProperties = new Properties(); serverProperties.loadFromXML(new FileInputStream("data/properties/serverproperties.xml")); int rcPort = Integer.parseInt(serverProperties.getProperty("RemoteControlPort", "0")); if (rcPort > 0) { groupRemoteControlListener(rcPort); } isaPeriod = Integer.parseInt(serverProperties.getProperty("ISAPeriod", "60")); isaNumChoices = Integer.parseInt(serverProperties.getProperty("ISANumChoices", "6")); for (int i = 0; i < 9; i++) { String tag = "ISAKeyText" + Integer.toString(i); String def_val = Integer.toString(i + 1); isakeytext[i] = serverProperties.getProperty(tag, def_val); } isaExtendedMode = serverProperties.getProperty("ISAExtendedMode", "false").equalsIgnoreCase("true"); } catch (Exception e) { log.error("Unable to start remote control listener"); log.error(e.getMessage()); } isaClients = new HashSet<Integer>(); }
From source file:org.colombbus.tangara.EditorFrame.java
/** * This method initializes the design of the frame. * *//*from w w w . j a v a 2s . c o m*/ private void initialize() { GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle bounds = graphicsEnvironment.getMaximumWindowBounds(); setPreferredSize(bounds.getSize()); this.setJMenuBar(getBanner()); this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // Sets the main menu (the one separated by jsplitPane1) this.setContentPane(getBasePanel()); this.setTitle(Messages.getString("EditorFrame.application.title")); //$NON-NLS-1$ addWindowListener(this.windowListener); try { // Associates the icon (frame.icon = icon_tangara.png) to Tangara URL url = EditorFrame.class.getResource(ICON_PATH); MediaTracker attenteChargement = new MediaTracker(this); Image image = Toolkit.getDefaultToolkit().getImage(url); attenteChargement.addImage(image, 0); attenteChargement.waitForAll(); setIconImage(image); } catch (InterruptedException e) { LOG.warn("Error while loading icon"); //$NON-NLS-1$ } // fileChooser allows to easily choose a file // when you open (FILE->OPEN...) you have the choice between .txt or // .tgr fileChooser = new JFileChooser(Program.instance().getCurrentDirectory()); // for TangaraFile ".tgr" fileChooser.addChoosableFileFilter(new FileFilter() { @Override public boolean accept(File f) { if (f.isDirectory()) return true; return FileUtils.isTangaraFile(f); } @Override public String getDescription() { return Messages.getString("EditorFrame.file.programFilesDescription"); //$NON-NLS-1$ } }); fileChooserWithoutFilter = new JFileChooser(Program.instance().getCurrentDirectory()); pack(); setVisible(true); setExtendedState(java.awt.Frame.MAXIMIZED_BOTH); }
From source file:org.pentaho.reporting.engine.classic.demo.ancient.demo.layouts.internalframe.InternalFrameDemoFrame.java
/** * Computes the maximum bounds of the current screen device. If this method is called on JDK 1.4, Xinerama-aware * results are returned. (See Sun-Bug-ID 4463949 for details). * * @return the maximum bounds of the current screen. *///from w ww .j ava 2 s.c om private static Rectangle getMaximumWindowBounds() { try { final GraphicsEnvironment localGraphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); return localGraphicsEnvironment.getMaximumWindowBounds(); } catch (Exception e) { // ignore ... will fail if this is not a JDK 1.4 .. } final Dimension s = Toolkit.getDefaultToolkit().getScreenSize(); return new Rectangle(0, 0, s.width, s.height); }
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 {/*from ww w . j a v a2 s . c o m*/ 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); }