Title: JAVA GUI???????
1JAVA GUI???????
?????????????? ???????
2?????
???????????????
public void paint(Graphics g)
g.drawLine(100,100,200,200)
g.drawLine(200,100,300,200)
??2??????
3???????????
public void paint(Graphics g)
g.setColor(Color.red) g.drawLine(100,100,200,2
00) g.setColor(Color.blue)
g.drawLine(200,100,300,200)
4????
setColor(?)??????????
??? Color.red Color.blue Color.yellow Color.white
??????????????
5???????
?????????3??(RGB) ? ? ? ???????????????????
6??
setColor(new Color(?,?,?)) ??????? 0255??????????
?? ???????????
7?
setColor(new Color(0,0,0))
??
setColor(new Color(255,255,255))
??
setColor(new Color(0,255,255))
???
setColor(new Color(125,125,125))
???
8??????????
public void paint(Graphics g)
g.setColor(new Color(200,0,150))
g.fillRect(100,100,200,50)
9??????
???????????????? ????????????(??????????)
??java?for??????????
10for?
for(??????????1??????)
? for(i1ilt5i)
i??i?1??????????? ???4????????
11for???????
public void paint(Graphics g) int i
for(i100ilt300i10)
g.drawLine(100,i,i,300)
i10?? i?10?????????? ??????????? ??????????
12for???????
public void paint(Graphics g) int i
for(i0ilt255i) g.setColor(new
Color(0,i,255-i)) g.drawLine(i,0,i,100)
???????? ?????!
13??????????
??????????????
14?????????
????????????-1,1-1,1????? ???????500500?????
???????(x,y)?? ??????(x,y)????
x250250x y250-250y ??????
15????????
????yx ?????????
2
???????????????????????? JAVA??????????????? ??(20
0,200)?????????? drawLine?????????????
drawLine(200,200,200,200)
16?????????
public void paint(Graphics g) double x,y
int x1,y1 for(x-1xlt1x0.01)
yxx x1(int)(250250x)
y1(int)(250-250y) g.drawLine(x1,y1,x1,y1)
17public void paint(Graphics g) double x,y
int x1,y1 for(x-1xlt1x0.01)
yxx x1(int)(250250x)
y1(int)(250-250y) g.drawLine(x1,y1,x1,y1)
?????????? x,y?double??????
18public void paint(Graphics g) double x,y
int x1,y1 for(x-1xlt1x0.01)
yxx x1(int)(250250x)
y1(int)(250-250y) g.drawLine(x1,y1,x1,y1)
????x1,y1??????? ??????????????? ???
19public void paint(Graphics g) double x,y
int x1,y1 for(x-1xlt1x0.01)
yxx x1(int)(250250x)
y1(int)(250-250y) g.drawLine(x1,y1,x1,y1)
x??1??1???0.01?? ?????????????
20public void paint(Graphics g) double x,y
int x1,y1 for(x-1xlt1x0.01)
yxx x1(int)(250250x)
y1(int)(250-250y) g.drawLine(x1,y1,x1,y1)
?????????
21public void paint(Graphics g) double x,y
int x1,y1 for(x-1xlt1x0.01)
yxx x1(int)(250250x)
y1(int)(250-250y) g.drawLine(x1,y1,x1,y1)
???????? ???????????????
???????????? ??????????
22public void paint(Graphics g) double x,y
int x1,y1 for(x-1xlt1x0.01)
yxx x1(int)(250250x)
y1(int)(250-250y) g.drawLine(x1,y1,x1,y1)
(x1,y1)???????
23?????????
?????? ??????? ??????????????????