java - JFrame size, resize, fullscreen -
my question have 3 parts.
- i know, how can set
jframe
window resizable, can not go under minim size user cant make smaller minimum size. - i know, how can set
jframe
window resizable, still keep aspect ratio (16:9) if user resizing it. - i know, how can make program become full screen after clicks button there no borders , runs game or (and if there specific issues how can revert safely).
thanks , patient not perfect english , not perfect java knowledge.
the provided answer useful , answers part of question, still of still blank me.
the part of code:
private void createdisplay() { graphicsdevice gd = graphicsenvironment.getlocalgraphicsenvironment().getdefaultscreendevice(); frame = new jframe(title); //setting title of window frame.setsize(width, height); //setting width , height of window frame.setdefaultcloseoperation(jframe.exit_on_close); //make sure program closes down frame.setresizable(true); frame.setlocationrelativeto(null); //the window apparel on center frame.setvisible(true); frame.seticonimage(assets.imagemap.get("icon")); canvas = new canvas(); canvas.setpreferredsize(new dimension(width, height)); canvas.setmaximumsize(new dimension(width, height)); canvas.setminimumsize(new dimension(gd.getdisplaymode().getwidth() / 2, gd.getdisplaymode().getheight() / 2)); canvas.setfocusable(false); frame.add(canvas); frame.pack(); //resize window little bit able see of canvas }
- set frame's minimum size (setminimumsize)
- is more difficult, notified of size change after fact, you'll fighting system changes (and run problems generated size change event). might better focus on keeping ratio of contents of frame based on available space within frame (vlc example of this)
- full screen exclusive mode
Comments
Post a Comment