Thursday, 6 February 2014

Java: How to get the size of the screen

private Dimension getScreenSize(String title)
       {
             Toolkit toolkit = getToolkit();
             Dimension screensize = toolkit.getScreenSize();
             return screensize;
       }

If this size is meant to be used for the frame that can be achieved as follows:

private void configureFrameWindow(String title)
       {
             setTitle(title);
             setDefaultLookAndFeelDecorated(true);
             Dimension screensize = getScreenSize();
             setPreferredSize(screensize);
             setMinimumSize(screensize);
ImageIcon icon = new ImageIcon(getClass().getResource("/resources/ icon.png"));
             if (icon != null) setIconImage(icon.getImage());
             setResizable(false);

       }

No comments:

Post a Comment