I got it working.  I subclassed a JPanel and drew my squares on that,
and then added the JPanel to my JFrames content pane

On Tue, 2004-10-26 at 11:04, Gurunath M. wrote:
> Hi Michael,
>       I think you may need to specify the layout for the pane.
>       Try adding
> 
>       pane = this.getContentPane();
>       pane.setLayout(new GridLayout());
> 
>       Hope it helps.
>       
>       --Guru
> 
> -----Original Message-----
> From: Michael Sullivan [mailto:[EMAIL PROTECTED] 
> Sent: Friday, October 22, 2004 11:10 PM
> To: [EMAIL PROTECTED]
> Subject: [javalearn] Graphics-type question
> 
> 
> My wife and I are working together on making a Java version of the board
> game Prosperity (don't worry if you've never heard of it.)  We just
> started tonight.  We wanted to the squares on the board objects.  We
> have a Square class and a Board class.  On the Board we define three
> squares.  The problem is that only the last of the three square shows
> up.  We can't seem to find why this is.  Can anyone help us?  I've
> pasted the code for both classes below.  They're not very developed
> yet...
> 
> import javax.swing.*;
> import java.awt.*;
> 
> public class Board extends JFrame
> {
>    Square square1, square2, square3;
>    Container pane;
>    
>    public Board()
>    {
>       this.setSize(800, 600);
>       this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>       this.setVisible(true);
> 
>       square1 = new Square(0, 0);
>       square2 = new Square(200, 200);
>       square3 = new Square(400, 400);
> 
>       pane = this.getContentPane();
>       pane.add(square1);
>       pane.add(square2);
>       pane.add(square3);
> 
>       this.setContentPane(pane);
>       this.show();
>    }
>    
>    public static void main(String board[])
>    {
>       new Board();
>    }
> }
> 
> 
> import java.awt.*;
> import javax.swing.JPanel;
> 
> class Square extends JPanel
> {
>    int x, y;
>    public Square(int x, int y)
>    {
>       this.x = x;
>       this.y = y;
>    }
> 
>    public void paintComponent(Graphics g)
>    {
>       g.setColor(Color.orange);
>       g.fillRect(x, y, 88, 66);
> 
>       g.setColor(Color.black);
>       g.drawRect(x, y, 88, 66);
>    }
> }
> 
> 
> 
> 
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 
> 
> 
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/5cFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To reply to this message, go to:
    http://groups.yahoo.com/group/beginnersclub/post?act=reply&messageNum=5367
    Please do not reply to this message via email. More information here:
    http://help.yahoo.com/help/us/groups/messages/messages-23.html

<*> To visit your group on the web, go to:  
    http://groups.yahoo.com/group/beginnersclub/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to