⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 webmenu.java

📁 我在学习JAVA的讲义
💻 JAVA
字号:
import java.net.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class WebMenu extends JApplet implements ActionListener {
    WebButton[] choices = new WebButton[3];

    public void init() {
        choices[0] = new WebButton("CUMT",
            "http://www.cumt.edu.cn/");
        choices[1] = new WebButton("Sina",
            "http://www.sina.com.cn/");
        choices[2] = new WebButton("google",
            "http://www.google.com");
        FlowLayout flo = new FlowLayout();
        getContentPane().setLayout(flo);
        for (int i = 0; i < choices.length; i++) {
            choices[i].addActionListener(this);
            getContentPane().add(choices[i]);
        }
    }

    public void actionPerformed(ActionEvent evt) {
        WebButton clicked = (WebButton)evt.getSource();
        try {
            URL load = new URL(clicked.address);
            getAppletContext().showDocument(load);
        } catch (MalformedURLException e) {
            showStatus("Bad URL:" + clicked.address);
        }
    }
}

class WebButton extends JButton {
    String address;

    WebButton(String iLabel, String iAddress) {
        super(iLabel);
        address = iAddress;
    }
}





⌨️ 快捷键说明

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