List of usage examples for java.awt Toolkit getScreenSize
public abstract Dimension getScreenSize() throws HeadlessException;
From source file:Main.java
public static void main(String[] args) { Toolkit tk = Toolkit.getDefaultToolkit(); Dimension d = tk.getScreenSize(); System.out.println("Screen width = " + d.width); System.out.println("Screen height = " + d.height); }
From source file:SizingWindowswithToolkit.java
public static void main(String[] args) { JFrame aWindow = new JFrame("This is the Window Title"); Toolkit theKit = aWindow.getToolkit(); Dimension wndSize = theKit.getScreenSize(); aWindow.setBounds(wndSize.width / 4, wndSize.height / 4, // Position wndSize.width / 2, wndSize.height / 2); // Size aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); aWindow.setVisible(true);/* ww w . j a va 2 s . c o m*/ }
From source file:CreatingCursors.java
public static void main(String[] args) { JFrame aWindow = new JFrame("This is the Window Title"); Toolkit theKit = aWindow.getToolkit(); // Get the window toolkit Dimension wndSize = theKit.getScreenSize(); // Get screen size // Set the position to screen center & size to half screen size aWindow.setBounds(wndSize.width / 4, wndSize.height / 4, // Position wndSize.width / 2, wndSize.height / 2); // Size aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); aWindow.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); aWindow.setVisible(true); // Display the window }
From source file:Capture.java
public static void main(String[] args) { JFrame capture = new JFrame(); capture.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Toolkit kit = Toolkit.getDefaultToolkit(); final Dimension d = kit.getScreenSize(); capture.setSize(d);//from w w w .j a v a 2 s. com Rectangle rect = new Rectangle(d); try { Robot robot = new Robot(); final BufferedImage image = robot.createScreenCapture(rect); image.flush(); JPanel panel = new JPanel() { public void paintComponent(Graphics g) { g.drawImage(image, 0, 0, d.width, d.height, this); } }; panel.setOpaque(false); panel.prepareImage(image, panel); panel.repaint(); capture.getContentPane().add(panel); } catch (Exception e) { e.printStackTrace(); } capture.setVisible(true); }
From source file:org.gridchem.client.GridChem.java
public static void main(String[] args) { Trace.entry();//from ww w . j av a 2 s. c om try { setCommandLineOptions(); parseCommandLine(args); } catch (Exception e) { System.out.println("Invalid command line option given: " + e.getMessage()); } //JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame(); // Edited by Shashank & Sandeep @ CCS,UKY April 10 2005 JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); /*MetalTheme theme = new G03Input.ColorTheme(); MetalLookAndFeel.setCurrentTheme(theme); try { UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); SwingUtilities.updateComponentTreeUI(frame); } catch(Exception e) { System.out.println(e); }*/ // Use the native look and feel since Java's is pretty lame. try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { // Ignore exceptions, which only result in the wrong look and feel. System.out.println("GridChem.main: an exception related to the" + " look and feel was ignored."); } init(); frame.setTitle("GridChem " + Env.getVersion()); frame.getContentPane().add(oc); frame.addWindowListener(new WindowListener() { public void windowActivated(WindowEvent arg0) { } public void windowClosed(WindowEvent arg0) { } public void windowClosing(WindowEvent arg0) { if (Settings.authenticated) { GMS3.logout(); } } public void windowDeactivated(WindowEvent arg0) { } public void windowDeiconified(WindowEvent arg0) { } public void windowIconified(WindowEvent arg0) { } public void windowOpened(WindowEvent arg0) { } }); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); // Centering the frame on the screen Toolkit kit = frame.getToolkit(); Dimension screenSize = kit.getScreenSize(); int screenWidth = screenSize.width; int screenHeight = screenSize.height; Dimension windowSize = frame.getSize(); int windowWidth = windowSize.width; int windowHeight = windowSize.height; int upperLeftX = (screenWidth - windowWidth) / 2; int upperLeftY = (screenHeight - windowHeight) / 2; frame.setLocation(upperLeftX, upperLeftY); frame.setVisible(true); Trace.exit(); }
From source file:GUI.AllForDealFrame.java
/** * @param args the command line arguments *//* w w w . j av a2 s . com*/ public static void main(String args[]) { Toolkit tk = Toolkit.getDefaultToolkit(); Dimension screenSize = tk.getScreenSize(); int screenHeight = screenSize.height; int screenWidth = screenSize.width; /* 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 ex) { java.util.logging.Logger.getLogger(AllForDealFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(AllForDealFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(AllForDealFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(AllForDealFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { try { AllForDealFrame fa = new AllForDealFrame(); fa.setVisible(true); //fa.setResizable(false); fa.setSize(1200, 700); //fa.setLocation(screenWidth/2 , screenHeight/2 ); tbCommentairesService.getColumnModel().getColumn(0).setMinWidth(0); tbCommentairesService.getColumnModel().getColumn(0).setMaxWidth(0); tbCommentairesService.getColumnModel().getColumn(0).setWidth(0); tbProduits.getColumnModel().getColumn(0).setMinWidth(0); tbProduits.getColumnModel().getColumn(0).setMaxWidth(0); tbProduits.getColumnModel().getColumn(0).setWidth(0); tblMesProduits.getColumnModel().getColumn(0).setMinWidth(0); tblMesProduits.getColumnModel().getColumn(0).setMaxWidth(0); tblMesProduits.getColumnModel().getColumn(0).setWidth(0); tbMesMsgR.getColumnModel().getColumn(0).setMinWidth(0); tbMesMsgR.getColumnModel().getColumn(0).setMaxWidth(0); tbMesMsgR.getColumnModel().getColumn(0).setWidth(0); tbMsgEnvs.getColumnModel().getColumn(0).setMinWidth(0); tbMsgEnvs.getColumnModel().getColumn(0).setMaxWidth(0); tbMsgEnvs.getColumnModel().getColumn(0).setWidth(0); } catch (UnsupportedLookAndFeelException ex) { Logger.getLogger(AllForDealFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (ParseException ex) { Logger.getLogger(AllForDealFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (java.text.ParseException ex) { Logger.getLogger(AllForDealFrame.class.getName()).log(Level.SEVERE, null, ex); } } }); }
From source file:Main.java
public static Dimension getScreenSize() { Toolkit tk = Toolkit.getDefaultToolkit(); return tk.getScreenSize(); }
From source file:Main.java
public static Rectangle getScreenSize() { Toolkit tk = Toolkit.getDefaultToolkit(); Dimension d = tk.getScreenSize(); return new Rectangle(0, 0, d.width, d.height); }
From source file:Main.java
public static Point getCenterPoint() { Toolkit toolkit = Toolkit.getDefaultToolkit(); double desktopHeight = toolkit.getScreenSize().getHeight(); double desktopWidth = toolkit.getScreenSize().getWidth(); return new Point((int) desktopWidth / 2, (int) desktopHeight / 2); }
From source file:Main.java
public static void center(Component component) { Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension screenSize = toolkit.getScreenSize(); int x = (screenSize.width - component.getWidth()) / 2; int y = (screenSize.height - component.getHeight()) / 2; component.setLocation(x, y);//from w w w . j a v a2s. c om }