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('$','@')