Advertisement
Shamel

lab solved

Jan 10th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.22 KB | None | 0 0
  1.  
  2.  
  3. import java.awt.*;
  4. import java.awt.event.*;
  5.  
  6. public class dumblab
  7. {
  8.     public static void main(String args[])
  9.     {
  10.         GfxApp gfx = new GfxApp();
  11.         gfx.setSize(1000,750);
  12.         gfx.addWindowListener(new WindowAdapter() {public void
  13.         windowClosing(WindowEvent e) {System.exit(0);}});
  14.         gfx.show();
  15.     }
  16. }
  17.  
  18. class GfxApp extends Frame
  19. {
  20.  
  21.     public void paint (Graphics g)
  22.     {
  23.         g.setColor(Color.black);
  24.         int maxX=1024;
  25.         int maxY=768;
  26.         drawSquare1(g,(maxX/2)-maxX/8,(maxY/2)-maxY/8,maxX/4,maxY/4,5);
  27.     }
  28.  
  29.     public void drawSquare1(Graphics g, int x, int y, int width,int height, int n)
  30.     {
  31.         if(width>1 && height>1){
  32.  
  33.         if (n == 5) g.fillRect(x,y,width,height);
  34.         if (n != 4) { g.fillRect(x-width/2,y-height/2,width/2,height/2);drawSquare1(g,x-width/2,y-height/2,width/2,height/2,1);}
  35.         if (n != 3) {g.fillRect(x+width,y-height/2,width/2, height/2);drawSquare1(g,x+width,y-height/2,width/2, height/2,2);}
  36.         if (n != 2){ g.fillRect(x-width/2,y+height,width/2,height/2);drawSquare1(g,x-width/2,y+height,width/2,height/2,3);}
  37.         if (n != 1){ g.fillRect(x+width,y+height,width/2,height/2);drawSquare1(g,x+width,y+height,width/2,height/2,4);}
  38. }
  39.     }
  40.  
  41.     private void delay(double n)
  42.     {
  43.         for (double k = 1; k < n; k+=0.001);
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement