For Programmers: Free Programming Magazines  


Home > Archive > Java Help > August 2005 > Re: adding a JPanel to a JPanel in the center layout









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: adding a JPanel to a JPanel in the center layout
Thomas Fritsch

2005-08-31, 6:59 pm

"Unknown" <unknownerror404@comcast.net> schrieb im Newsbeitrag
news:UIGdnZ2dnZ3xDRXLnZ2dnXGDiN6dnZ2dRVn
-yZ2dnZ0@comcast.com...
> Hi all! I'm writting an implementation for a mastermind game. I have a
> class that represents all the holes in which the user can click on to
> guess the appropriate sequence of pegs. When I add an object(extends
> JPanel and overrides the paintcomponent to display images as the holes) to
> another JPanel in the BorderLayout.CENTER, it still positions the Panel
> far to the left in the center of the root panel. If you have any
> suggestions, thanks ahead of time!

OK, you did something like
panel1.add(panel2, BorderLayout.CENTER);

May be you missed
panel1.setLayout(new BorderLayout());
at the beginning. Then panel1 still would have its default layout, which
happens to be FlowLayout.
--
"TFritsch$t-online:de".replace(':','.').replace('$','@')


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com