Forum Stats

  • 3,769,832 Users
  • 2,253,027 Discussions
  • 7,875,218 Comments

Discussions

How can I get Desktop size?

843807
843807 Member Posts: 46,582
edited Oct 7, 2002 2:57PM in Java Desktop Applications
I can get Screen size using DefaultToolkit.getScreenSize()
but, How can I get Desktop size which is the Screen size without taskbar in the window?

Comments

  • 843807
    843807 Member Posts: 46,582
    Under Java 1.4 you could use
    frame.show();
    frame.setExtendedState(Frame.MAXIMIZED_BOTH);
    Dimension size = frame.getSize();
    This should return the right values for you.

    Regards,
    Tim
  • 843807
    843807 Member Posts: 46,582
    Or, easier and works in earlier versions:

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

    Tuomas Rinta
  • 843807
    843807 Member Posts: 46,582
    Oopps... should have read the question properly... sorry :)

    Tuomas Rinta
  • 843807
    843807 Member Posts: 46,582
    The code below won't work correctly if you are using the new setDefaultLookAndFeelDecorated method.

    Another Tim :-)
    Under Java 1.4 you could use
    frame.show();
    frame.setExtendedState(Frame.MAXIMIZED_BOTH);
    Dimension size = frame.getSize();
    This should return the right values for you.

    Regards,
    Tim
  • 843807
    843807 Member Posts: 46,582
    Last week I was looking for the same thing, and didn't think of the Toolkit at all. Thank you for pointing this out, and I'll try that. However, instead, I wrote the following
        DisplayMode dMode      = null;
    
            GraphicsConfiguration gc = getGraphicsConfiguration();
            GraphicsDevice        gd = gc.getDevice();
            dMode = gd.getDisplayMode();
    
        int width = dMode.getWidth();
        int height = dMode.getHeight();
    - David
This discussion has been closed.