java - Finding Screen Size -
i trying find size of screen , utilize dimension window.
jframe window = new jframe(); dimension screensize = toolkit.getdefaulttoolkit().getscreensize(); int width = screensize.getwidth(); int height = screensize.getheight(); window.setsize(width, height); window.setvisible(true); window.settitle("game"); window.setdefaultcloseoperation(jframe.exit_on_close);
it gives me next errors:
game.java:7: error: cannot find symbol dimension screensize = toolkit.getdefaulttoolkit().getscreensize(); ^ symbol: class dimension location: class game game.java:7: error: cannot find symbol dimension screensize = toolkit.getdefaulttoolkit().getscreensize(); ^ symbol: variable toolkit location: class game 2 errors
tool completed exit code 1
did remember import java.awt.toolkit
?
besides, bad way this, expend under "extra" content many oss have on screen (the taskbar on windows example), , displayed underneath it.
instead, utilize jframe#setextendedstate
, pass jframe. maximized_both
maximise window fills entire application viewable area.
now, if want window occupy entire screen, you're going have take @ full screen exclusive mode, bring it's own issues
if want know "viewable" size of screen (that area application windows should appear within), utilize like...
rectangle bounds = new rectangle(0, 0, 0, 0); graphicsenvironment ge = graphicsenvironment.getlocalgraphicsenvironment(); gd = ge.getdefaultscreendevice(); graphicsconfiguration gc = gd.getdefaultconfiguration(); bounds = gc.getbounds(); insets insets = toolkit.getdefaulttoolkit().getscreeninsets(gc); bounds.x += insets.left; bounds.y += insets.top; bounds.width -= (insets.left + insets.right); bounds.height -= (insets.top + insets.bottom);
which homecoming viewable space of desktop minus scheme stuff...
java swing size screen
No comments:
Post a Comment