问答题
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/*
*/
public class ex10_3 extends JApplet {
JButton jb = new JButton("Add Text");
JTextPane jtp = new JTextPane();
public void init() {
jb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
for(int i = 1; i < 10; i++)
jtp.geText(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(0);
}
});
frm.getContentPane().add(ex10_3);
frm.setSize(300, 400);
frm.setVisible(true);
}
}
ex10_3.html