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

📄 frame1.java~6~

📁 关于internet的程序源码
💻 JAVA~6~
字号:
package url;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;import java.net.Inet4Address.*;import java.net.*;public class Frame1 extends JFrame {  JPanel contentPane;  XYLayout xYLayout1 = new XYLayout();  JButton jButton1 = new JButton();  JLabel jLabel1 = new JLabel();  JLabel jLabel2 = new JLabel();  JLabel jLabel3 = new JLabel();  JLabel jLabel4 = new JLabel();  JTextField jTextField1 = new JTextField();  //Construct the frame  public Frame1() {    enableEvents(AWTEvent.WINDOW_EVENT_MASK);    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  //Component initialization  private void jbInit() throws Exception  {    contentPane = (JPanel) this.getContentPane();    jButton1.setText("查询URL信息");    jButton1.addActionListener(new Frame1_jButton1_actionAdapter(this));    contentPane.setLayout(xYLayout1);    this.setSize(new Dimension(400, 300));    this.setTitle("Frame Title");    jLabel1.setText("jLabel1");    jLabel2.setText("jLabel2");    jLabel3.setText("jLabel3");    jLabel4.setText("jLabel4");    jTextField1.setText("http://news.sina.com.cn:80/index.html");    contentPane.add(jLabel3, new XYConstraints(44, 140, 271, 23));    contentPane.add(jLabel4,  new XYConstraints(46, 166, 299, 22));    contentPane.add(jLabel1, new XYConstraints(43, 82, 267, 23));    contentPane.add(jLabel2,  new XYConstraints(43, 109, 281, 33));    contentPane.add(jButton1, new XYConstraints(91, 214, 203, 24));    contentPane.add(jTextField1,  new XYConstraints(24, 28, 357, 33));  }  //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 jButton1_actionPerformed(ActionEvent e) {    try{      URL myurl = new URL(jTextField1.getText());      jLabel1.setText("您输入的URL 的协议为:"+myurl.getProtocol());      jLabel2.setText("您输入的URL 的主机为:"+myurl.getHost());      jLabel3.setText("您输入的URL 的文件名:"+myurl.getFile());      jLabel4.setText("您输入的URL 连接的端口为:"+myurl.getPort());    }catch (MalformedURLException ex){      ex.printStackTrace();    }  }}class Frame1_jButton1_actionAdapter implements java.awt.event.ActionListener {  Frame1 adaptee;  Frame1_jButton1_actionAdapter(Frame1 adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton1_actionPerformed(e);  }}

⌨️ 快捷键说明

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