Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / August 2005

Tip: Looking for answers? Try searching our database.

Help: adding a JPanel to a JPanel in the center layout

Thread view: 
Unknown - 30 Aug 2005 23:44 GMT
 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!

B
Andrew Thompson - 31 Aug 2005 05:42 GMT
>   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)

Why not use a GridLayout?

>..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, ..

Tell us exactly what you're doing, in code..
<http://www.physci.org/codes/sscce.jsp>

Signature

Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
"Give me a whiskey, don't think twice.."
The Angels 'Marseille'

Roedy Green - 31 Aug 2005 11:14 GMT
>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!

You could try a GridBagLayout which has insets for controlling the
fine positioning.  see http://mindprod.com/jgloss/gridbaglayout.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Thomas Fritsch - 31 Aug 2005 19:59 GMT
>  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
[quoted text clipped - 3 lines]
> 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.
Signature

"TFritsch$t-online:de".replace(':','.').replace('$','@')



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.