📄 applet1.java
字号:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.util.Enumeration ;
public class Applet1 extends Applet implements ActionListener
{
private TextArea textArea;
private String newline;
public void init()
{
Button b=new Button("Click to call getApplets()");
b.addActionListener(this);
setLayout(new BorderLayout());
add("North",b);
textArea=new TextArea(5,40);
textArea.setEditable(false);
add("Center",textArea);
newline=System.getProperty("line.separator");
}
public void actionPerformed(ActionEvent event){
printApplets();
}
public String getAppletInfo(){
return "GetApplets by Dong,li";
}
public void printApplets(){
Enumeration e=getAppletContext().getApplets();
textArea.append("Results of getApplets();"+newline);
while(e.hasMoreElements()){
Applet applet=(Applet)e.nextElement();
String info=((Applet)applet).getAppletInfo();
if(info!=null){
textArea.append("-"+info+newline);
}else{
textArea.append("-"+applet.getClass().getName()+newline);
}
}
textArea.append("_______________________"+newline+newline);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -