Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.12 KB | None | 0 0
  1. package zadanie2linie;
  2.  
  3. import javax.microedition.lcdui.Canvas;
  4. import javax.microedition.lcdui.Graphics;
  5.  
  6. /**
  7.  *
  8.  * @author Let
  9.  */
  10. public class Plotno extends Canvas {
  11.  
  12.     protected void paint(Graphics g) {
  13.         g.setColor(255,255,255);
  14.         g.fillRect(0, 0, this.getWidth(), this.getHeight());
  15.         int x1 = 0;
  16.         int x2=this.getWidth();
  17.         int y1 = 0;
  18.         int y2= this.getHeight();
  19.        
  20.         for (int i = 0;i<=(this.getHeight()/20);i++){
  21.         g.setColor(0,0,0);
  22.         g.drawLine(x1, y1, x2, y2);
  23.         y1=y1+20;
  24.         y2=y2-20;
  25.         }
  26.         x2=0;
  27.         x1 = 0;
  28.         y1 = 0;
  29.         y2= this.getHeight();
  30.        
  31.          for (int i = 0;i<=this.getHeight()/10;i++){
  32.         g.setColor(0,0,0);
  33.         g.drawLine(x1, y1, x2 ,y2 );
  34.         x2=x2+10;
  35.         y1=y1+10;
  36.         }
  37.         x2=0;
  38.         x1 = this.getWidth();
  39.         y1 = 0;
  40.         y2= 0;
  41.           for (int i = 0;i<=this.getHeight()/10;i++){
  42.         g.setColor(0,0,0);
  43.         g.drawLine(x1, y1, x2 ,y2 );
  44.         y1=y1+10;
  45.         x2=x2+10;
  46.         }      
  47.     }
  48.    
  49.    
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement