import javax.swing .*;
import java.awt .*;
public class Line extends JPanel {
; int x1 = 0;
  int y1=32;
  int x2=10;
  int y2=50;
  int x0=50;
  int y0;
  public void paintComponent(Graphics g){
    x2=this.getWidth();
    y0=getHeight()-50;
    y2=(int)1.8*x2+32;
    g.setColor(Color.RED);
    g.drawLine(x1+x0,y0-y1,x2+x0,y0-y2);
    g.setColor(Color.BLUE);
    g.drawLine(x0,y0,x2-20,y0);     g.drawLine(x0,y0,x0,50);
  }
}        import javax.swing.*;
     import javax.swing.*;    
     JFrame f1=new JFrame("testa retta");     
     f1.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); 
 line r = new Line (); 
 f1.setSize (500.500); 
 f1.add (r); 
 f1.setVisible (true);} 
 
} 
 
 
 
 
 
 
 
 
 
 
 
 
0 comments:
Post a Comment