java - Gray bars on bottom and right side while using graphics -


on every game make using usual graphics, end getting gray bars on right side , bottom of window.

you can see here: http://i.stack.imgur.com/qtxr6.png

any appreciated!

edit

main(string args[]) method

    main component = new main();     jframe frame = new jframe();     frame.add(component);     frame.pack();     frame.setresizable(false);     frame.setlocationrelativeto(null);     frame.setdefaultcloseoperation(jframe.exit_on_close);     frame.setvisible(true);     frame.settitle(name);     component.start(); 

render method

    public void render() {     graphics g = screen.getgraphics();     // drawings     g.setcolor(new color(255, 255, 255));     g.fillrect(0, 0, screenpixel.width, screenpixel.height);     level.render(g);     for(entity e:entity.entities){         e.render(g);     }      g = getgraphics();     g.drawimage(screen, 0, 0, screensize.width, screensize.height, 0, 0, screenpixel.width, screenpixel.height, null);     g.dispose();     } 

answered madprogrammer:

call setresizable before pack, call pack before setvisible , after you've established ui. use actual know values width , height (getwidth , getheight) not screensize.width or screensize.height


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -