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 Sponsor --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/5cFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To reply to this message, go to:
    http://groups.yahoo.com/group/beginnersclub/post?act=reply&messageNum=5338
    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