I'm working on a java program that will display 4 black squares in a certain pattern, and have them scale proportionally with the frame if it is resized. I have drawn the first two squares, however I am unable to draw squares on the right side or bottom of the frame while still making them scale when the frame is resized. Any help would be appreciated:
public void paint(Graphics g)
{
g.setColor(Color.white);
int w = getWidth();
int h = getHeight();
g.fillRect(0,0,w,h);
Graphics2D g2 = (Graphics2D)g;
g2.setColor(Color.black);
Rectangle r1 = new Rectangle(0, h/3, w/3, h/3);
g2.fill(r1);
g2.setColor(Color.black);
Rectangle r2 = new Rectangle(w/3, h/500, w/3, h/3);
g2.fill(r2);
g2.setColor(Color.black);
Rectangle r3 = new Rectangle(w/2, h/3, w/3, h/3);
g2.fill(r3);
}
public static void main(String[] args)
{
Test2Frame w = new Test2Frame();
w.setVisible(true);
}
}