applet2.java
来自「java网络高级编程的配套源码,java网络高级编程为清华出版社出版.」· Java 代码 · 共 80 行
JAVA
80 行
/*源程序清单4-10*/
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import borland.jbcl.layout.*;
import borland.jbcl.control.*;
public class Applet2 extends Applet
{
XYLayout xYLayout1 = new XYLayout();
boolean isStandalone = false;
Button button1 = new Button();
TextField textField1 = new TextField();
Label label1 = new Label();
AppletContext ac=null;
Applet applet=null;
//Construct the applet
public Applet2() {
}
//Initialize the applet
public void init()
{
try
{
jbInit();
}
catch (Exception e)
{
e.printStackTrace();
}
}
private void jbInit() throws Exception
{
this.setBackground(new Color(192,192,192));
xYLayout1.setWidth(400);
xYLayout1.setHeight(139);
button1.setLabel("发送数据到左面的applet");
button1.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(ActionEvent e)
{
button1_actionPerformed(e);
}
});
label1.setText("请输入你所需要发送的数据");
this.setLayout(xYLayout1);
this.add(button1, new XYConstraints(15, 75, 254, 32));
this.add(textField1, new XYConstraints(15, 33, 260, 30));
this.add(label1, new XYConstraints(16, 4, 257, 24));
ac=this.getAppletContext();
applet=ac.getApplet("applet2");
}
//Get Applet information
public String getAppletInfo()
{
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo()
{
return null;
}
void button1_actionPerformed(ActionEvent e)
{
String msg=textField1.getText();
if(msg==null||msg.equals(""))
return;
TextArea textArea=(TextArea)applet.getComponent(2);
textArea.append(msg+"\n");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?