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

📄 frame1.java~22~

📁 可以实现用对话框控制浏览器进行打开相应网址。
💻 JAVA~22~
字号:
package webpages;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.io.*;public class Frame1 extends JFrame {  JPanel contentPane;  GridLayout gridLayout1 = new GridLayout();  Button button1 = new Button();  Button button2 = new Button();  Button button3 = new Button();  Button button4 = new Button();  /**Construct the frame*/  public Frame1() {    enableEvents(AWTEvent.WINDOW_EVENT_MASK);    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  /**Component initialization*/  private void jbInit() throws Exception  {    //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));    contentPane = (JPanel) this.getContentPane();    button1.setLabel("ACMilan足球队主页");    button1.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        button1_actionPerformed(e);      }    });    gridLayout1.setRows(2);    gridLayout1.setColumns(2);    gridLayout1.setHgap(10);    gridLayout1.setVgap(10);    contentPane.setLayout(gridLayout1);    this.setResizable(false);    this.setSize(new Dimension(341, 265));    this.setTitle("调用Web页面");    button2.setLabel("Yahoo网站主页");    button2.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        button2_actionPerformed(e);      }    });    button3.setLabel("新浪网主页");    button3.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        button3_actionPerformed(e);      }    });    button4.setLabel("Inprise公司JBuilder主页");    button4.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        button4_actionPerformed(e);      }    });    contentPane.add(button1, null);    contentPane.add(button3, null);    contentPane.add(button2, null);    contentPane.add(button4, null);  }  /**Overridden so we can exit when window is closed*/  protected void processWindowEvent(WindowEvent e) {    super.processWindowEvent(e);    if (e.getID() == WindowEvent.WINDOW_CLOSING) {      System.exit(0);    }  }  void button1_actionPerformed(ActionEvent e) {      try{        String command =          "C:\\Program Files\\Internet Explorer\\Iexplore.exe www.acmilan.it";        Process child = Runtime.getRuntime().exec(command);      }catch(IOException ex){}  }  void button3_actionPerformed(ActionEvent e) {     try{        String command =          "C:\\Program Files\\Internet Explorer\\Iexplore.exe www.sina.com.cn";        Process child = Runtime.getRuntime().exec(command);      }catch(IOException ex){}  }  void button2_actionPerformed(ActionEvent e) {     try{        String command =          "C:\\Program Files\\Internet Explorer\\Iexplore.exe www.yahoo.com";        Process child = Runtime.getRuntime().exec(command);      }catch(IOException ex){}  }  void button4_actionPerformed(ActionEvent e) {     try{        String command =          "C:\\Program Files\\Internet Explorer\\Iexplore.exe www.inprise.com\\jbuilder";        Process child = Runtime.getRuntime().exec(command);      }catch(IOException ex){}  }}

⌨️ 快捷键说明

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