swing - Java GUI Panels -


i trying make game 1 of classes, running trouble in implementing of things want do. essentially, want multiple different parts inside same graphical user interface window.

to understanding use jpanels create these different parts , put them in larger jpanel, right in this?

i have code here, need on going of this.

public class farklewindow extends jframe{      private int windowwidth = 800;     private int windowheight = 600;      private jpanel player1dice, player2dice, dicepanel, infobox;     private farkledisplay gameboard;public farklewindow()     {         this.settitle("farkle!");         this.setsize(windowwidth,windowheight);         this.setdefaultcloseoperation(jframe.exit_on_close);          inititalizewindow();          this.setvisible(true);      }       private void inititalizewindow() {         gameboard = new farkledisplay();          this.add(gameboard, borderlayout.center);          //addmenuoptions();          player1dice = new jpanel();         gameboard.add(player1dice);      } } 

i know put in initializewindow() part create different parts, , how tell visible, border or color or see there.

any appreciated!

edit

i reading more on this, , @ have more questions. can make jpanels sizes, or through specific positioning can fit want?

edit v2

so said should include more information on kind of layout want interface, , thank guys have! still getting used using , posting stack overflow rather searching looking on it.

basically going , looking build similar layout

http://bestbackgammon.com/farkle/index_files/image001.jpg

i want each part separate panel, if way go it. having 2 side rectangles panels , center square panel, , fourth panel brown text box type thing inside middle square.

would decent way go that?

(also, tips on should improve question in general good.)

what put in initializewindow() part create different parts,

player1dice = new jpanel(); gameboard.add(player1dice); 

you can like:

jpanel panel1 = new jpanel(); panel1.setbackground( color.green ); gameboard.add(panel1); jpanel panel2 = new jpanel(); panel2.setbackground( color.blue ); gameboard.add(panel2); 

of course there won't see because panel doesn't contain components. question vague give specific answer.

and how tell visible, border or color or see there.

you can add border panel. like:

panel.setborder( borderfactory.createlineborder(color.red) );  

read section swing tutorial on how use borders more information.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -