List of usage examples for javax.swing JFrame getExtendedState
public int getExtendedState()
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame() { @Override/* w w w . j a v a 2 s . c om*/ public synchronized void setExtendedState(int state) { if (isUndecorated() && (state & MAXIMIZED_BOTH) == MAXIMIZED_BOTH) { super.setMaximizedBounds(new Rectangle(300, 300)); } super.setExtendedState(state); } }; frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(800, 600); frame.setUndecorated(true); frame.getContentPane().add(new JButton(new AbstractAction("Toggle maximize") { @Override public void actionPerformed(ActionEvent e) { int state = frame.getExtendedState(); if ((state & JFrame.MAXIMIZED_BOTH) == JFrame.MAXIMIZED_BOTH) { frame.setExtendedState(JFrame.NORMAL); } else { frame.setExtendedState(JFrame.MAXIMIZED_BOTH); } } }), BorderLayout.PAGE_END); frame.setVisible(true); }
From source file:org.samjoey.gui.GraphicalViewer.java
/** * @param args the command line arguments *///from w ww . ja v a2 s. c o m public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(GraphicalViewer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { javax.swing.JFrame gv = new GraphicalViewer(); gv.setVisible(true); gv.setExtendedState(gv.getExtendedState() | javax.swing.JFrame.MAXIMIZED_BOTH); } }); }
From source file:Main.java
/** This method alternatingly maximizes or restores the window. */ public static void zoom(JFrame frame) { int both = JFrame.MAXIMIZED_BOTH; frame.setExtendedState((frame.getExtendedState() & both) != both ? both : JFrame.NORMAL); }
From source file:Main.java
/** * @return Returns <code>true</code> if the frame is visible, showing and not * iconified./* w w w.java2s . c o m*/ */ public static boolean isVisibleNotMinimized(JFrame frame) { assertEventDispatcherThread(); return (frame.isVisible() && frame.isShowing() && (frame.getExtendedState() & JFrame.ICONIFIED) == 0); }
From source file:Main.java
public static void run(final JFrame f) { SwingUtilities.invokeLater(new Runnable() { public void run() { f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.pack();/*from w w w . j a va 2 s.c o m*/ f.setVisible(true); f.setExtendedState(f.getExtendedState() | JFrame.MAXIMIZED_BOTH); } }); }
From source file:app.SimpleLifecycleAdvisor.java
/** * Called when the application has fully started. This is after the initial application window has been made * visible.// w w w .j a v a 2 s. co m */ public void onPostStartup() { if (logger.isInfoEnabled()) { logger.info("onPostStartup()"); } JFrame frame = this.getOpeningWindow().getControl(); //System.out.println(this.getOpeningWindow().getControl()); frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH); }
From source file:com.tag.FramePreferences.java
public void install() { windowStateListener = new WindowStateListener() { public void windowStateChanged(WindowEvent e) { Object source = e.getSource(); if (source instanceof JFrame) { JFrame frame = (JFrame) source; int extendedState = frame.getExtendedState(); if (extendedState == JFrame.ICONIFIED) return; Preferences prefs = getPreferences(); prefs.putInt(KEY_EXTENDED_STATE, extendedState); }//from www . j av a2 s. c om } }; frame.addWindowStateListener(windowStateListener); componentListener = new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { Preferences prefs = getPreferences(); Dimension size = frame.getSize(); prefs.putInt(KEY_WIDTH, size.width); prefs.putInt(KEY_HEIGHT, size.height); } @Override public void componentMoved(ComponentEvent e) { Preferences prefs = getPreferences(); Point location = frame.getLocation(); prefs.putInt(KEY_X, location.x); prefs.putInt(KEY_Y, location.y); } }; frame.addComponentListener(componentListener); }
From source file:de.erdesignerng.util.ApplicationPreferences.java
/** * Update the last position of a window. * * @param aAlias the alias of the window * @param aWindow the window/* w ww . j a va 2s.co m*/ */ public void updateWindowDefinition(String aAlias, JFrame aWindow) { windowDefinitions.put(WINDOWSTATEPREFIX + aAlias, "" + aWindow.getExtendedState()); updateWindowLocation(aAlias, aWindow); updateWindowSize(aAlias, aWindow); }
From source file:Main.java
void initUI() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); int i = 1;/* w ww. ja v a 2 s . c o m*/ for (GraphicsDevice gd : ge.getScreenDevices()) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(createLabel(String.valueOf(i))); frame.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "exit"); frame.getRootPane().getActionMap().put("exit", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { System.exit(0); } }); frame.setLocation(gd.getDefaultConfiguration().getBounds().getLocation()); frame.setUndecorated(true); frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH); frame.setVisible(true); gd.setFullScreenWindow(frame); i++; } }
From source file:org.sunzoft.sunstock.StockMain.java
protected void initGUI() { final JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(1024, 600);/*w w w.java2 s .co m*/ frame.setLocationRelativeTo(null); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { // Container contentPane = frame.getContentPane(); contentPane.setLayout(new BorderLayout(0, 0)); JFreeChart chart = createChart(); // 6:chartPanel chartPanel = new ChartPanel(chart); chartPanel.setMouseZoomable(true); contentPane.add(chartPanel, BorderLayout.CENTER); JPanel pCtrl = new JPanel(); if (profits.size() > 0) { startInput.setText(profits.get(0).date); endInput.setText(profits.get(profits.size() - 1).date); } else { startInput.setText("20100101"); endInput.setText("20100101"); } pCtrl.add(new JLabel("")); pCtrl.add(startInput); pCtrl.add(new JLabel("")); pCtrl.add(endInput); JButton confirm = new JButton(""); confirm.addActionListener(StockMain.this); pCtrl.add(confirm); contentPane.add(pCtrl, BorderLayout.NORTH); JPanel pStatus = new JPanel(); statusLabel = new JLabel(getStatusText()); pStatus.add(statusLabel); contentPane.add(pStatus, BorderLayout.SOUTH); frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH); frame.setVisible(true); //dataSource.close(); } }); }