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();
}
} 展开
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();
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询