lunedì 1 febbraio 2010

esercizio 01/02/10

import java.awt.*;
import javax.swing.*;
public class Retta4 extends JPanel{
int x1=0;
int y1=32;
int x2=10;
int y2=50;
int x0=100;
int y0=100;

public void paintComponenti(Graphics g){
x2=this.getWidth();
y2=(int) 1.8*x2+32;
g.setColor(Color.RED);
g.drawLine(x1,y1,x2,y2);
g.setColor(Color.BLUE);
g.drawLine(x0,y0,this.getWidth()-10,y0);
g.drawLine(x0,y0,x0,this.getHeight()-20);
g.setColor(Color.GREEN);
g.drawLine(x0,32+y0,-17+x0,32+y0);

}
}

Nessun commento: