问答题
import javax.swing.* ;
import java.awt.*;
import java.awt.event.*;
/*
<applet code="ex10_3.class"width = 800 height=400>
</applet>
*/
public class ex10_3 extends JApplet {
JButton jb = new JButton("Add Text");
JTextPane itp = new JTextPane();
public void init() {
jb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
for(int i = 1;i<10;i++)
jtp.getText(jtp.setText()+"Welcome to the NCR Examination!\n");
}
});
Container cp = getContentPane();
cp.add(new JScrollPane(jtp));
cp.add(BorderLayout.SOUTH,jtp);
}
public static void main(String[]args) {
ex10_3 obj10_3=new ex10_3();
String str = obj10_3.getClass().toString();
if(str.indexOf("class") != -1)
str = str.substring(6);
JFrame frm = new JFrame(str);
frm.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.exit(O);
}
});
frm.getContentPane().add(ex10_3);
frm.setSize(300, 400);
frm.setVisible(true);
}
}
ex10_3.html
<HTML>
<HEAD>
<TITLE>ex10_3</TITLE>
</HEAD>
<BODY>
<applet code="exl0_3.class" width=800 height=400 >
</applet>
</BODY>
</HTML>