3
Java, Internet, , WWW. , , , (, , ..), " ", .
. 1. Java-
. , Web, , , , .. - Web .
, - , , , . , . - . , web- , web- .
, , . . , .
, .
, . , . - , , , web-.
JApplet javax.swing.
, Applet. , . , .
- JApplet Applet. JApplet , . . , , Applet.
.
public void init()
start(). , - .
public void start()
"" . , , , , . stop , , . stop , start .
|
|
public void stop()
, . stop destroy.
public void destroy()
.
init() . (listeners) , .
Java , ( , ).
, Applet, , .
Init
init . .
Start
start init. , .
, init , start HTML-, , . , , WWW-, , start.
Paint
paint . AWT , , , . , , , paint.
Update
update Applet , paint. paint , update , , . , update. update, paint, AWT, update.
Stop
stop , HTML-, . stop . , . , , start.
Destroy
destroy , (, Netscape) , . , .
Repaint
repaint . , , update. , , update . AWT, update . , repaint (time) , .
|
|
repaint(time)
repaint, ( repaint).
repaint (x, , w, h)
, , .
repaint(time, x, , w, h)
.
,
: , .
:
- , ;
- () Swing, .;
:
- . JTextField, JButton JLabel. , .
- JPanel . " "; - " ". "" BorderLayout.
- 2 , "" , .
- 2 , , , . , ArrayList.
- 2 "". . , TreeSet.
- y = a-√x*cos(ax). JLabel, ": = a-√x * cos(ax)"; , JTextField, , (, 0.1) . =0. , . , .
- , , ..
- , GIF-, .
- (, , ). . .
- . 1 9.
- . "", "", "", "" . .
- ( ). "" . .
- . , .
- 12 , "" .
- . , .
- ( ) / /.
|
|
1
, " ", , "".
// AppDemo.java AppDemo.java:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class AppDemo extends JApplet {
JTextField txt = new JTextField(15);
public AppDemo() {}
public void init() {
Container c = getContentPane();
c.setLayout(new FlowLayout());
JLabel lbl = new JLabel(" ");
c.add(lbl);
JButton btn = new JButton(" ");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
txt.setText("");
}
});
c.add(btn);
c.add(txt);
} }
. JFrame JApplet getContentPane(). .. Java, init().
web-, . HTML-. , AppDemo
<html>
<head><title>First Applet</title></head>
<body>
-
<applet code=AppDemo width=400 height=200>
</applet>
</body>
</html>
, HTML, . <applet>. code, width height. code. , , jar-, archive applet. AppDemo.shtml, , .4.
.2.