?? line.java
字號:
import java.applet.Applet;
import java.util.Scanner;
import java.awt.Color;
import java.awt.Graphics;
public class Line extends Applet{
private int x0,y0;
private int x1,y1;
public void init()
{
Scanner scanner = new Scanner(System.in);
System.out.println("please input four Integer numbers:");
x0 = scanner.nextInt();
y0 = scanner.nextInt();
x1 = scanner.nextInt();
y1 = scanner.nextInt();
}
public void paint(Graphics g){
int x;
float dy,dx,y,m;
dx = x1-x0;
dy = y1-y0;
m=dy/dx;
y=y0;
g.setColor(Color.red);
for(x = x0;x <= x1;x++){
{g.drawString(".", x, (int)(y+0.5));
y+=m;
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -