?? sameapplettestb.java
字號:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class SameAppletTestb extends Applet implements ActionListener{
private final String waitingMessage = "Waiting for a message...";
private Label labObj = new Label(waitingMessage,Label.RIGHT);
private TextArea taObj;
private String lineObj;
private String nameObj;
public void init(){
GridBagLayout gridBag = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
setLayout(gridBag);
/*添加提示信息和“清除”按鈕*/
Button butObj = new Button("清除");
gridBag.setConstraints(labObj,c);
add(labObj);
c.gridwidth = GridBagConstraints.REMAINDER;
gridBag.setConstraints(butObj,c);
add(butObj);
butObj.addActionListener(this);
/*添加文本區顯示發送方傳來的信息*/
taObj = new TextArea(5,40);
taObj.setEditable(false);
c.anchor = GridBagConstraints.CENTER;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1.0;
c.weighty = 1.0;
gridBag.setConstraints(taObj,c);
add(taObj);
/*顯示當前Applet的名稱*/
nameObj = getParameter("NAME");
Label sendLabel = new Label("My Name is "+ nameObj +".",Label.CENTER);
c.weightx = 0.0;
c.weighty = 0.0;
gridBag.setConstraints(sendLabel,c);
add(sendLabel);
}
public void actionPerformed(ActionEvent event){
labObj.setText(waitingMessage);
taObj.setText("");
}
public void processRequestFrom(String senderName,String conStr){
lineObj = System.getProperty("line.separator");
labObj.setText(" Received message from "+senderName +"!");
taObj.append(conStr+lineObj);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -