[求助]MINI浏览器源程序的错误
<P>大家好,能帮我看下这个程序是错在哪吗?<BR>不甚感激。。。。。<BR>import java.io.IOException;<BR>import java.net.URL;<BR>import javax.swing.*;<BR>import java.awt.*;<BR>import java.awt.event.*;</P><P>public class wtllq extends JFrame<BR>{<BR> JPanel contentPane;<BR> BorderLayout borderLayoutAll=new BorderLayout();<BR> JLabel jLabelprompt=new JLabel();<BR> JPanel jPanelMain=new JPanel();<BR> BorderLayout borderLayoutMain=new BorderLayout();<BR> JTextField textFieldURL=new JTextField();<BR> JEditorPane jEditorPane=new JEditorPane();<BR> public wtllq()<BR> {<BR> try<BR> {<BR> Init();<BR> }catch(Exception e){e.printStackTrace();}<BR> }<BR> private void Init() throws Exception<BR> {<BR> contentPane=(JPanel)getContentPane();<BR> contentPane.setLayout(borderLayoutAll);<BR> jPanelMain.setLayout(borderLayoutMain);<BR> jLabelprompt.setText("请输入URL");<BR> textFieldURL.setText("");<BR> textFieldURL.addActionListener(new java.awt.event.ActionListener(){<BR> public void actionPerformed(ActionEvent e){<BR> textFieldURL_actionPerformed(e);<BR> }<BR> });<BR> jEditorPane.setEditable(false);<BR> jEditorPane.addHyperlinkListener(new javax.swing.event.HyperlinkListener(){<BR> public void hyperlinkUpdate(HyperlinkEvent e){<BR> jEditorPane_hyperlinkUpdate(e);<BR> }<BR> });<BR> JScrollPane scrollPane=new JScrollPane();<BR> scrollPane.getViewport().add(jEditorPane);<BR> jPanelMain.add(textFieldURL,"North");<BR> jPanelMain.add(scrollPane,"Center");<BR> contentPane.add(jLabelprompt,"North");<BR> contentPane.add(jPanelMain,"Centre");<BR> enableEvents(AWTEvent.WINDOW_EVENT_MASK);<BR> this.setSize(new Dimension(600,500));<BR> this.setTitle("xpj迷你浏览器");<BR> this.setVisible(true);<BR> }<BR> void textFieldURL_actionPerformed(ActionEvent e){<BR> try{<BR> jEditorPane.setPage(textFieldURL.getText());<BR> }catch(IOException ex){<BR> JOptionPane msg=new JOptionPane();<BR> JOptionPane.showMessageDialog(this,"URL地址不正确:"+textFieldURL.getText(),"输入不正确",0);<BR> }<BR> }<BR> void jEditorPane_hyperlinkUpdate(HyperlinkEvent e)<BR> {<BR> if(e.getEventType()==javax.swing.event.HyperlinkEvent.EventType.ACTIVATED){<BR> try{<BR> URL url=e.getURL();<BR> jEditorPane.setPage(url);<BR> textFieldURL.setText(url.toString());<BR> }catch(IOException io){<BR> JOptionPane msg=new JOptionPane();<BR> JOptionPane.showMessageDialog(this,"打开该链接失败!","输入不正确!",0);<BR> }<BR> }<BR> }<BR> protected void processWindowEvent(WindowEvent e){<BR> super.processWindowEvent(e);<BR> if(e.getID()==WindowEvent.WINDOW_CLOSING){<BR> System.exit(0);<BR> }<BR> }<BR> public static void main(String[] args){<BR> new wtllq();<BR> }<BR>}</P>
页:
[1]
