?? sender.java
字號:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Sender extends Applet implements ActionListener
{
private String myName;
private TextField nameField;
private TextArea status;
private String newline; //設置各種私有變量,用于表示各種信息
public void init()
{
GridBagLayout gridBag=new GridBagLayout();
GridBagConstraints c =new GridBagConstraints();
setLayout(gridBag);
Label receiverLabel=new Label("接收名稱是:",Label.RIGHT);
gridBag.setConstraints(receiverLabel,c);
add(receiverLabel);//添加接收信息標簽
nameField=new TextField(getParameter("REVEIVERNAME"),10);
c.fill=GridBagConstraints.HORIZONTAL;
gridBag.setConstraints(nameField,c);
add(nameField);
nameField.addActionListener(this);
Button button=new Button("發送信息");
c.gridwidth=GridBagConstraints.REMAINDER;
c.anchor=GridBagConstraints.WEST;
c.fill=GridBagConstraints.NONE;
gridBag.setConstraints(button,c);
add(button);//添加按鈕信息
button.addActionListener(this);//添加按鍵事件
status=new TextArea(5,60);
status.setEditable(false);//設置狀態欄
c.anchor=GridBagConstraints.CENTER;
c.fill=GridBagConstraints.BOTH;
c.weightx=1.0;
c.weighty=1.0;
gridBag.setConstraints(status,c);
add(status);
myName=getParameter("NAME");//獲得Applet的名字,此時"name"屬性是在HTML頁面上添加的
Label senderLabel=new Label("(我的名字是 "+"<"+myName+">"+")",Label.CENTER);
c.weightx=0.0;
c.weighty=0.0;
gridBag.setConstraints(senderLabel,c);
add(senderLabel);//完成添加標簽
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -