code37_2.txt

来自「《计算机网络与因特网》(原书第4版) 作者:Douglas Comer博士 」· 文本 代码 · 共 35 行

TXT
35
字号
import java.applet.*;import java.net.*;import java.awt.*;public class buttons extends Applet {  public void init() {    setBackground(Color.white);    add(new Button("Ying"));    add(new Button("Yang"));  }  public boolean action(Event e, Object arg) {    if (((Button) e.target).getLabel() == "Ying") {      try {	getAppletContext().showDocument(	   new URL("http://www.netbook.cs.purdue.edu/cs363/lecture_notes/chap29/ying.html"));      }      catch (Exception ex) {	// note: code to handle the exception goes here //		   }    }    else if (((Button) e.target).getLabel() == "Yang") {      try {	getAppletContext().showDocument(	   new URL("http://www.netbook.cs.purdue.edu/cs363/lecture_notes/chap29/yang.html"));      }      catch (Exception ex) {	// note: code to handle the exception goes here //		   }    }    return true;  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?