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); /* g2.setColor(Color.black); Rectangle r4 = new Rectangle(0, h/2, w/3, h/2); g2.fill(r4);*/ } // copied from the W2MouseEvents for convenience // (so we can run the program from Test2Panel class too!) public static void main(String[] args) { Test2Frame w = new Test2Frame(); w.setVisible(true); } }
componentResized(ComponentEvent e)
h
w
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)