| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 441 人关注过本帖
标题:请教高手,我的程序出了什么问题
只看楼主 加入收藏
lianqiao
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-12-21
收藏
 问题点数:0 回复次数:1 
请教高手,我的程序出了什么问题

import java.io.IOException;
import java.net.URL;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;

public class WebBrowser extends JFrame
{
JPanel contentPane;
BorderLayout borderLayoutAll = new BorderLayout();
JLabel jLabelPrompt = new JLabel();
JPanel jPaneMain = new JPanel();
BorderLayout borderLayoutMain = new BorderLayout();
JTextField textFieldURL = new JTextField();
JEditorPane jEditorPane = new JEditorPane();

public WebBrowser()
{
try
{
Init();
}catch(Exception e){
e.printStackTrace();
}
}


private void Init() 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.HyperlinkEvent()
{
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(jLablePrompt,"North");
contentPane.add(jPaneMain,"Center");
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
this.setSize(new Dimension(600,500));
this.setTitle("胖胖专用浏览器");
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 WebBrowser();
}
}

2005-12-21 16:20
yanghl
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2005-12-21
收藏
得分:0 
太长了,你也不说具体出了什么错,我们也不好看啊!呵呵

与Java共存亡!!
2005-12-21 18:29
快速回复:请教高手,我的程序出了什么问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011850 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved