Advertisement
| 10.26.2008 at 05:12PM PDT, ID: 23849241 | Points: 500 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: |
public class CanadaFlag extends JPanel {
public CanadaFlag() {
}
public void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
Rectangle flag = new Rectangle();
flag.setBounds(this.getBounds());
int h = (int)flag.getHeight();
int w = (int)flag.getWidth();
int xCoord = (int)flag.getX();
int yCoord = (int)flag.getY();
g2.setColor(Color.WHITE);
g2.fillRect(xCoord,yCoord,w,h); //this only draws it in the
//topleft.
//here is where i call the panel:
public class FlagsFrame extends JFrame {
public FlagsFrame() {
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension dimensions = toolkit.getScreenSize();
int height = dimensions.height;
setBounds(0,0,height,height);
setLayout(new GridLayout(2,2));
add(new CanadaFlag());
add(new CanadaFlag());
add(new CanadaFlag());
add(new CanadaFlag());
setTitle("Designed by Eric Totte: Canadian-Olympic");
}
}
|
Advertisement