drawLine 是哪个类里的 java

importjava.awt.Color;importjava.awt.Frame;importjava.awt.Graphics;//importjava.awt.Pa... import java.awt.Color;
import java.awt.Frame;
import java.awt.Graphics;
//import java.awt.Panel;

class WindowsDemo extends Frame
{
int size=5;
int gridLen=30;
int c = 10;
int d = 30;

public WindowsDemo(String title)
{
super(title);
}

public void init() {
super.setSize(1000,1000);
super.setBackground(Color.GREEN);
super.setBounds(100,100,300,300);
super.setLayout(null);
super.setVisible(true);

}

public void paint(Graphics g) {
//super.paint(g);
//g.setColor(Color.BLACK);

int b = 10;
//g.drawLine(40+b*gridLen, 40, 40+b*gridLen, 40+b*gridLen);

//System.out.println(size);
//System.out.println(c);
//System.out.println(d);
g.drawLine(c, c, d, d);
g.drawLine(40, 40+b*gridLen, 40+size*gridLen, 40+b*gridLen);
for(int i=0;i<=size;i++){
g.drawLine(40+i*gridLen, 40, 40+i*gridLen, 40+size*gridLen);
g.drawLine(40, 40+i*gridLen, 40+size*gridLen, 40+i*gridLen);
}

}

}

class punct
{
private int x,y,x1,y1,x2,y2;

punct()
{
}

punct (int x , int y)
{
this.x =x;
this.y =y;

}

void print(int x, int y)
{
System.out.println();
System.out.println("die Koordinate ist (" +x+","+y+ ")");

}

int[] setLocatio(int x0, int y0)
{
x1 = x0;
y1 = y0;

String a = this.toString(x1 ,y1 );
System.out.print("Die Koordinate ist (");
for( int i=0;i<a.length();i++ )
{
System.out.print( a.charAt(i) );
}

System.out.print(")");

int[] arr1 = {x1,x2};

return arr1;

}
// String toString

public String toString(int A, int B)
{

String a = String.valueOf(A);
String b = String.valueOf(B);
String s = a+","+b;

return s;
}

// void translate(int dx, int dy)
void translate(int dx, int dy)
{
x2=x1 + dx;
y2=y1 + dy;
this.print(this.x2, this.y2);

}

}

public class DrawWindows {

public static void main(String[] args) {
// TODO Auto-generated method stu
punct p = new punct();

p.setLocatio(100,100);
p.translate(100,100);
new WindowsDemo("WindowsDemo").init();

}

}
展开
 我来答
Mexico卡卡
2017-11-19 · TA获得超过1万个赞
知道大有可为答主
回答量:1.3万
采纳率:98%
帮助的人:1884万
展开全部
drawLine(int x1, int y1, int x2, int y2)
x1,y1 为起点的坐标

x2,y2 为终点的坐标
还有什么?
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式