📄 echoapplet.java
字号:
//EchoApplet.java
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import java.net.URL;
import java.io.*;
public class EchoApplet extends Applet {
String servletPath="http://10.9.41.41:8080/servlet/EchoServlet";
private URL clientIP;
TextField textField1 = new TextField();
Button button1 = new Button();
//Construct the applet
public EchoApplet() {
}
//Initialize the applet
public void init() {
try {
clientIP=this.getCodeBase();
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
textField1.setBounds(new Rectangle(97, 73, 145, 23));
this.setSize(new Dimension(400,300));
this.setLayout(null);
button1.setBounds(new Rectangle(140, 124, 55, 23));
button1.setLabel("确定");
button1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
button1_actionPerformed(e);
}
});
this.add(textField1, null);
this.add(button1, null);
}
void button1_actionPerformed(ActionEvent e){
try{
DataInputStream in = new DataInputStream(new URL(servletPath).openStream());
String rl=in.readLine();
if(rl==null)
textField1.setText ("Error Occur");
else
textField1.setText (rl);
}
catch(Exception ex){
ex.printStackTrace ();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -