要每一行都有注解的,详细点 。具体点就是每一行都什么功能
我明天急用啊import java.io.IOException;
import java.net.URL;
import javax.swing.*;
import javax.swing.text.Document;
import javax.swing.text.JTextComponent;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
public class HtmlBrowser extends JFrame {
JPanel contentPane;              
BorderLayout borderLayoutAll = new BorderLayout();
JLabel jLabelPrompt = new JLabel();   
JPanel jPanelMain = new JPanel();
BorderLayout borderLayoutMain = new BorderLayout();
JTextField textFieldURL = new JTextField();       
JEditorPane jEditorPane = new JEditorPane();      public HtmlBrowser() {  
try {
jbInit();                             
}
catch(Exception e) {
e.printStackTrace();
}
}private void jbInit() throws Exception  {        
contentPane = (JPanel)getContentPane();
contentPane.setLayout(borderLayoutAll);
jPanelMain.setLayout(borderLayoutMain);
jLabelPrompt.setText("请输入URL");
textFieldURL.setText(""); // 清空文本框
textFieldURL.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
textFieldURL_actionPerformed(e); }
});
jEditorPane.setEditable(false);
jEditorPane.addHyperlinkListener(new javax.swing.event.HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
jEditorPane_hyperlinkUpdate(e);
        }
});
JScrollPane scrollPane = new JScrollPane();
scrollPane.getViewport().add(jEditorPane);
jPanelMain.add(textFieldURL, "North");
jPanelMain.add(scrollPane, "Center");
contentPane.add(jLabelPrompt, "North");
contentPane.add(jPanelMain, "Center");
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
this.setSize(new Dimension(600, 500));
this.setTitle("迷你IE ");
this.setVisible(true);
}void textFieldURL_actionPerformed(ActionEvent e) { try {
jEditorPane.setPage(textFieldURL.getText());          
}
    catch(IOException ex) {
JOptionPane msg = new JOptionPane();
JOptionPane.showMessageDialog(this, "URL地址不正确:"+textFieldURL.getText(), "输入不正确!", 0);
    }
}void jEditorPane_hyperlinkUpdate(HyperlinkEvent e) {      
if(e.getEventType() == javax.swing.event.HyperlinkEvent.EventType.ACTIVATED) {
try {
URL url = e.getURL();                       
jEditorPane.setPage(url);                          
textFieldURL.setText(url.toString());                 
}
catch(IOException io){
JOptionPane msg = new JOptionPane();
JOptionPane.showMessageDialog(this, "打开该链接失败!", "输入不正确!", 0);
}
}
}protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);                            
}
}public static void main(String[] args) { 
    new HtmlBrowser();
}
}

解决方案 »

  1.   

    帮D一个!"每一行",没有时间呀
    而且像这行处么:
    try {建议:楼主说明一下,主要部分写就可以了,剩余自己加呀
      

  2.   

    像 try{  就不用了啊
      

  3.   

    /////就会这些,我也不是很会写注释,不过看起来楼主是想做一个很简单的网页浏览器,让用户输入URL,给他创建连接。
    /**
     * The extends classes
     */
    import java.io.IOException;
    import java.net.URL;
    import javax.swing.*;
    import javax.swing.text.Document;
    import javax.swing.text.JTextComponent;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    public class HtmlBrowser extends JFrame {
    JPanel contentPane;   //控件面板容器           
    BorderLayout borderLayoutAll = new BorderLayout();//画面布局
    JLabel jLabelPrompt = new JLabel();   //标签
    JPanel jPanelMain = new JPanel();//主面板
    BorderLayout borderLayoutMain = new BorderLayout();//画面布局
    JTextField textFieldURL = new JTextField();       //URL输入文本
    JEditorPane jEditorPane = new JEditorPane();      //文本框/**
     *构造函数 
     *初始化
     */
    public HtmlBrowser() {  
    try {
    jbInit();                             
    }
    catch(Exception e) {
    e.printStackTrace();
    }
    }private void jbInit() throws Exception  {        
    contentPane = (JPanel)getContentPane();
    contentPane.setLayout(borderLayoutAll);
    jPanelMain.setLayout(borderLayoutMain);
    jLabelPrompt.setText("请输入URL");
    textFieldURL.setText(""); // 清空文本框
    textFieldURL.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e) {
    textFieldURL_actionPerformed(e); }
    });
    jEditorPane.setEditable(false);
    jEditorPane.addHyperlinkListener(new javax.swing.event.HyperlinkListener() {
    public void hyperlinkUpdate(HyperlinkEvent e) {
    jEditorPane_hyperlinkUpdate(e);
            }
    });
    //画面设置
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.getViewport().add(jEditorPane);
    jPanelMain.add(textFieldURL, "North");
    jPanelMain.add(scrollPane, "Center");
    contentPane.add(jLabelPrompt, "North");
    contentPane.add(jPanelMain, "Center");
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    this.setSize(new Dimension(600, 500));
    this.setTitle("迷你IE ");
    this.setVisible(true);
    }void textFieldURL_actionPerformed(ActionEvent e) { try {
    jEditorPane.setPage(textFieldURL.getText());          
    }
        catch(IOException ex) {
    JOptionPane msg = new JOptionPane();
    JOptionPane.showMessageDialog(this, "URL地址不正确:"+textFieldURL.getText(), "输入不正确!", 0);
        }
    }void jEditorPane_hyperlinkUpdate(HyperlinkEvent e) {      
    if(e.getEventType() == javax.swing.event.HyperlinkEvent.EventType.ACTIVATED) {
    try {
    URL url = e.getURL();  //获取连接                     
    jEditorPane.setPage(url);                          
    textFieldURL.setText(url.toString()); //连接地址                
    }
    catch(IOException io){
    JOptionPane msg = new JOptionPane();//新建消息窗口
    JOptionPane.showMessageDialog(this, "打开该链接失败!", "输入不正确!", 0);//弹出错误信息
    }
    }
    }/**
     * 关闭窗口
     */
    protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
    System.exit(0); //退出系统                           
    }
    }public static void main(String[] args) { 
        new HtmlBrowser();
    }
    }
      

  4.   

    /***
     *
     *画面初始化设置。
     */private void jbInit() throws Exception  {        
    contentPane = (JPanel)getContentPane();
    contentPane.setLayout(borderLayoutAll);
    jPanelMain.setLayout(borderLayoutMain);
    jLabelPrompt.setText("请输入URL");
    textFieldURL.setText(""); // 清空文本框
    textFieldURL.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e) {
    textFieldURL_actionPerformed(e); }
    });
    jEditorPane.setEditable(false);
    jEditorPane.addHyperlinkListener(new javax.swing.event.HyperlinkListener() {
    public void hyperlinkUpdate(HyperlinkEvent e) {
    jEditorPane_hyperlinkUpdate(e);
            }
      

  5.   

    欢迎加入Java学习讨论群:32998944(程序人生)