List of usage examples for javax.swing JFrame setExtendedState
public void setExtendedState(int state)
From source file:Main.java
public static void main(String[] args) { JFrame frame1 = new JFrame(); frame1.setExtendedState(JFrame.MAXIMIZED_BOTH); frame1.setUndecorated(true);/*from w w w. ja v a 2s .c o m*/ frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame1.setVisible(true); JDialog nonModalDialog = new JDialog(frame1, "Non-Modal Dialog", ModalityType.MODELESS); nonModalDialog.add(Box.createRigidArea(new Dimension(200, 200))); nonModalDialog.pack(); nonModalDialog.setVisible(true); JDialog modalDialog = new JDialog(frame1, "Modal Dialog", ModalityType.APPLICATION_MODAL); modalDialog.add(Box.createRigidArea(new Dimension(200, 200))); modalDialog.pack(); modalDialog.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame() { @Override//from w w w . j a va 2 s . c o m 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 ww w.j a v a 2 s . com 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
/** * Maximizes a JFrame, just like the 'maximize window' button does. * <p>/* w w w.j av a2s . com*/ * @param f The frame to maximize. */ public static void maximizeJFrame(JFrame f) { f.setExtendedState(Frame.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
public static void run(final JFrame f) { SwingUtilities.invokeLater(new Runnable() { public void run() { f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.pack();// ww w. j a va 2s . c o m f.setVisible(true); f.setExtendedState(f.getExtendedState() | JFrame.MAXIMIZED_BOTH); } }); }
From source file:Main.java
/** * Mostra uma caixa de menssagem para que seja ensirido um valor. * @param frame/*from w w w . ja va 2 s .c o m*/ * @param texto * @param title * @param valorInicial * @param type * @return * @author Thiago Benega * @since 13/04/2009 */ public static String showTextboxDialog(javax.swing.JFrame frame, String texto, String title, String valorInicial, int type) { Object txt = null; JDialog jDialog = new JDialog(); jDialog.setTitle(title); jDialog.setFocusableWindowState(true); if (frame != null) { frame.setExtendedState(Frame.ICONIFIED); frame.pack(); frame.setExtendedState(Frame.MAXIMIZED_BOTH); } switch (type) { case JOptionPane.OK_CANCEL_OPTION: txt = JOptionPane.showInputDialog(jDialog, texto, title, type, null, null, valorInicial);//.toString(); break; case JOptionPane.YES_NO_OPTION: txt = JOptionPane.showConfirmDialog(jDialog, texto, title, type, JOptionPane.INFORMATION_MESSAGE); break; default: JOptionPane.showMessageDialog(jDialog, texto, title, type); break; } jDialog = null; return txt != null ? txt.toString() : null; }
From source file:Main.java
static void createFrameAtLocation(Point p) { JFrame frame = new JFrame(); frame.setTitle("Test frame on two screens"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(new BorderLayout()); JTextArea textareaA = new JTextArea(24, 80); textareaA.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1)); panel.add(textareaA, BorderLayout.CENTER); frame.setLocation(p);/* ww w. ja va2s.co m*/ frame.add(panel); frame.pack(); frame.setExtendedState(Frame.MAXIMIZED_BOTH); frame.setVisible(true); }
From source file:Main.java
/** * Centers the frame on the screen and sets its bounds. THis method should be * used after you call frame.pack() or frame.setSize(). * @param frame/*from w w w .ja va 2 s . co m*/ */ public static void centerFrame(JFrame frame) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Point center = ge.getCenterPoint(); Rectangle bounds = ge.getMaximumWindowBounds(); int w = Math.max(bounds.width / 2, Math.min(frame.getWidth(), bounds.width)); int h = Math.max(bounds.height / 2, Math.min(frame.getHeight(), bounds.height)); int x = center.x - w / 2, y = center.y - h / 2; frame.setBounds(x, y, w, h); if ((w == bounds.width) && (h == bounds.height)) { frame.setExtendedState(Frame.MAXIMIZED_BOTH); } frame.validate(); }
From source file:de.kletterfreak98.xmass.ui.BMIChart.java
public void start() { JFrame frame = this; frame.setSize(new Dimension(1000, 500)); frame.setExtendedState(JFrame.MAXIMIZED_BOTH); RefineryUtilities.centerFrameOnScreen(frame); frame.setVisible(true);/*from w w w.j av a 2 s . c o m*/ }