Title: JAVA GUI???????
1JAVA GUI???????
?1?
2?1? ??
- ? JAVA????????
- ? html????????
- ? ????????
- ? JAVA???????????
- ? ?????
3?JAVA??????????
?????????????????????? ???H???????????? ??????Exam
ple1.java???? ???????????????????? ??????????????
?????????
4import java.awt. import javax.swing. public
class Example1 extends JApplet public void
init() public void paint(Graphics g)
5?html???????
???HTML???????????? ????????ex1.html??????
6lthtmlgt ltheadgt lttitlegt????JAVAlt/titlegt lt/headgt ltb
ody bgcolor"00FFFF"gt ltpgtltapplet
codeExample1.class" width"500" height"500"gtlt/a
ppletgtlt/pgt lt/bodygt lt/htmlgt
7lthtmlgt ltheadgt lttitlegt????JAVAlt/titlegt lt/headgt ltb
ody bgcolor"00FFFF"gt ltpgtltapplet
codeExample1.class" width"500" height"500"gtlt/a
ppletgtlt/pgt lt/bodygt lt/htmlgt
JAVA???? Example1? ?500 ??500???
8?JAVA?????????
????????????????? ???MS-DOS???????????
9????? C?windowsgt ?????????????? ?????????H??????
????????? ????????
10C?windoswgt ????cd h? ???????? ????? H?gt ??????
??
11C?windoswgt ????cd h? ???????? ????? H?gt ??????
??
cd?? change directory??? ??????????????
MS-DOS??UNIX??????
12???????
JAVA??????? Javac ????? ??????Example1.java???
javac Example1.java ???????
13?????????????
??????????????????? ?????????????????????? ??????
??????
14html????????
??????ex1.html????????? Internet
Explorer?????500??500???? ??????? ???????????
15JAVA?????????
???????Example1.java????????????
16import java.awt. import javax.swing. public
class Example1 extends JApplet public void
init() public void paint(Graphics g)
17import java.awt. import javax.swing. public
class Example1 extends JApplet public void
init() public void paint(Graphics g)
import???? C??include????? ????????????
18import java.awt. import javax.swing. public
class Example1 extends JApplet public void
init() public void paint(Graphics g)
Example1????????????? ??Example1.java?????? ???
??????????????
19import java.awt. import javax.swing. public
class Example1 extends JApplet public void
init() public void paint(Graphics g)
??????????????????? ?????????????
20import java.awt. import javax.swing. public
class Example1 extends JApplet public void
init() public void paint(Graphics g)
?????? ?????????????? ?????????????
21??????
???????????????????
22 drawLine
drawLine(x1,y1,x2,y2) ?(x1?y1)???(x2?y2)???????
drawLine(100,100,200,200) ????(100,100)??(200,20
0)???????
23 drawRect
drawRect(x1,y1,w,h) ?(x1?y1)???w???h?????????
24 fillRect
fillRect(x1,y1,w,h) ?(x1?y1)???w,??h,????????????
??
25 drawOval
drawOval(x1,y1,w,h) ?(x1?y1)???w???h?????????????
?
26 fillOval
drawOval(x1,y1,w,h) ?(x1?y1)???w???h?????????????
???????
27??????????
public void paint(Graphics g)
g.drawLine(100,100,200,200)
g.drawOval(200,100,50,50) g.fillRect(100,300,8
0,40) g.drawRect(300,100,50,80)
28?1? ???
???????????????????????