Java game - layout -


i'm making tetris in java , have few questions layout in reference picture below:

should gameboard , scoreboard separated 2 jpanels within 1 jframe... set jframe size equal gameboard + scoreboard?

jframe f = new jframe("tetris");   f.setsize(gameboard.getwidth()+scoreboard.getwidth(), gameboard.getheight()); 

or should 1 jpanel within 1 jframe contains everything...? (here set frame equal size of gameboard + 200 on right have space show buttons, score, next piece, etc...) if so, how align buttons , such?

jframe f = new jframe("tetris");   f.setsize(gameboard.getwidth()+200, gameboard.getheight()); 

any thoughts on how should lay out game?

enter image description here

  • don't use setsize. use layout, position components, , call f.pack. automatically size window correctly.

  • you should have more 1 jpanel. two-panel layout looks good.

for example:

jpanel contentpane = new jpanel(new borderlayout()); contentpane.add(maingamepanel, borderlayout.center); contentpane.add(scorepanel, borderlayout.east); f.setcontentpane(contentpane); f.pack(); 

see using layout managers more information.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -