1 | public void paint( Graphics g ) { |
2 | Graphics2D g2d = ( Graphics2D ) g; |
3 | g2d.setColor( Color.red ); |
4 | GeneralPath rect = new GeneralPath( GeneralPath.EVEN_ODD ); |
5 | rect.moveTo( 300.0f, 300.0f ); // ul corner |
6 | rect.lineTo( 500.0f, 300.0f ); // ur corner |
7 | rect.lineTo( 500.0f, 400.0f ); // lr corner |
8 | rect.lineTo( 300.0f, 400.0f ); // ll corner |
9 | rect.closePath(); // close the rectangle |
10 | g2d.fill( rect ); |
11 | } |