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

📄 frame1.java~4~

📁 本程序是运用java 语言 编写一款查看 网站源文件的程序
💻 JAVA~4~
字号:
package seehtml;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;import java.io.*;import java.net.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class Frame1 extends JFrame {  JPanel contentPane;  XYLayout xYLayout1 = new XYLayout();  JLabel jLabel1 = new JLabel();  JTextField jTextField1 = new JTextField();  JLabel jLabel2 = new JLabel();  JLabel jLabel3 = new JLabel();  JLabel jLabel4 = new JLabel();  JLabel jLabel5 = new JLabel();  JLabel jLabel6 = new JLabel();  JScrollPane jScrollPane1 = new JScrollPane();  JTextArea jTextArea1 = new JTextArea();  //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();    jLabel1.setText("请输入网址:");    contentPane.setLayout(xYLayout1);    this.setSize(new Dimension(537, 455));    this.setTitle("Frame Title");    jTextField1.setText("http://");    jTextField1.addActionListener(new Frame1_jTextField1_actionAdapter(this));    jLabel2.setText("网络协议:");    jLabel3.setText("网络主机名:");    jLabel4.setText("文件名:");    jLabel5.setText("端口:");    jLabel6.setText("源文件:");    jTextArea1.setText("");    jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);    contentPane.add(jTextField1,  new XYConstraints(198, 16, 233, 32));    contentPane.add(jLabel1, new XYConstraints(55, 18, 91, 31));    contentPane.add(jLabel2,    new XYConstraints(60, 80, 370, 30));    contentPane.add(jLabel4,  new XYConstraints(60, 140, 370, 30));    contentPane.add(jLabel3,  new XYConstraints(60, 110, 370, 30));    contentPane.add(jLabel5,   new XYConstraints(60, 170, 370, 30));    contentPane.add(jLabel6, new XYConstraints(59, 198, 134, 26));    contentPane.add(jScrollPane1,  new XYConstraints(57, 227, 454, 217));    jScrollPane1.getViewport().add(jTextArea1, 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 jTextField1_actionPerformed(ActionEvent e) {    try{    URL myurl=new URL(jTextField1.getText());    jLabel2.setText("输入的URL协议: "+myurl.getProtocol());    jLabel3.setText("URL主机: "+myurl.getHost());    jLabel4.setText("URL文件名: "+myurl.getFile());    jLabel5.setText("URL断口: "+myurl.getPort());        }        catch (MalformedURLException ex) {ex.printStackTrace();}    try{                  StringBuffer buf=new StringBuffer();                  URL myurl=new URL(jTextField1.getText());                  URLConnection uc=myurl.openConnection();                  InputStream raw=uc.getInputStream();                  InputStream buffer=new BufferedInputStream(raw);                  Reader r=new InputStreamReader(buffer);                  int c;                  while((c=r.read())!=-1){                    buf.append((char)c);                  }                  jTextArea1.append(buf.toString());            }                catch(IOException ex){ex.printStackTrace();}  }}class Frame1_jTextField1_actionAdapter implements java.awt.event.ActionListener {  Frame1 adaptee;  Frame1_jTextField1_actionAdapter(Frame1 adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jTextField1_actionPerformed(e);  }}

⌨️ 快捷键说明

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