Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package awtHomework2b;
- import java.awt.*;
- import java.awt.event.*;
- class GraphicsPanel extends Panel {
- public void paint( Graphics g ) {
- g.setColor( Color.blue );
- g.fillRect( 10, 10, 300, 300);
- g.setColor( getBackground());
- g.fillRoundRect(25, 25, 270, 270, 20, 20);
- g.setColor( Color.red );
- g.fillRect( 40, 40, 120, 120 );
- g.setColor( Color.blue );
- g.fillOval( 40, 40, 240, 240 );
- g.setColor( getBackground());
- g.fillArc( 40, 40, 240, 240, 90, 90);
- }
- }
- public class AWTHomework2b extends Frame {
- public AWTHomework2b() {
- GraphicsPanel gp = new GraphicsPanel();
- this.setTitle("GraphicsDemo");
- this.setSize(340,360);
- this.add( gp );
- this.setVisible(true);
- this.addWindowListener( new WindowClosing());
- }
- public static void main(String[] args) {
- new AWTHomework2b();
- }
- class WindowClosing extends WindowAdapter {
- public void windowClosing( WindowEvent e) {
- System.exit(0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment