example12_3.java

来自「不错的教程 适合中高级人员的使用」· Java 代码 · 共 24 行

JAVA
24
字号
import java.applet.*;import java.awt.*;
import java.awt.event.*;import java.net.*;
public class Example12_3 extends Applet implements ActionListener
{  Button button;
   URL url;
   TextField text;
   public void init()
   {  text=new TextField(18);
      button=new Button("确定");
      add(new Label("输入网址:"));add(text); add(button);
     button.addActionListener(this);
   }
   public void actionPerformed(ActionEvent e)
   {  if(e.getSource()==button)
       {  try {  url=new URL(text.getText().trim());
                 getAppletContext().showDocument(url);
              }
          catch(MalformedURLException g)
             {  text.setText("不正确的URL:"+url);
             }
       }
   }
}

⌨️ 快捷键说明

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