
帮忙调试一个Java程序,做的是一个简单的浏览器,谢谢
importjavax.swing.*;importjava.awt.*;importjava.awt.event.*;importjava.net.*;importja...
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import javax.swing.event.*;
public class llq{
public static void main(String args[]){
new WinTwo();
}
}
class WinTwo extends JFrame implements ActionListener,Runnable{
JButton button;
URL url;
JTextField text;
JEditorPane editPane;
byte b[]=new byte[118];
Thread thread;
public WinTwo(){
text=new JTextField(20);
editPane=new JEditorPane();
editPane.setEditable(false);
button=new JButton("确定");
thread=new Thread(this);
JPanel p=new JPanel();
p.add(new JLabel("输入网址:"));
p.add(text);
p.add(button);
Container con=getContentPane();
con.add(new JScrollPane(editPane),BorderLayout.CENTER);
con.add(p,BorderLayout.NORTH);
setBounds(60,60,360,300);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
editPane.addHyperlinkListener(new HyperlinkListener(){
public void hyperlinkUpdate(HyperlinkEvent e){
if(e.getEventType()==HyperlinkEvent.EventType.ACTIVATED){
try{editPane.setPage(e.getURL());}
catch(IOException e1){editPane.setText(""+e1);}
}
}});
}
public void actionPerfomed(ActionEvent e){
if(!(thread.isAlive()))
thread=new Thread(this);
try{thread.start();}
catch(Exception ee){text.setText("正在读取"+url);}
}
public void run(){
try { int n=-1;
editPane.setText(null);
url=new URL(text.getText().trim());
editPane.setPage(url);
}
catch(MalformedURLException e1){
text.setText(""+e1);
return;
}
catch(IOException e1){
text.setText(""+e1);
return;
}
}
} 展开
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import javax.swing.event.*;
public class llq{
public static void main(String args[]){
new WinTwo();
}
}
class WinTwo extends JFrame implements ActionListener,Runnable{
JButton button;
URL url;
JTextField text;
JEditorPane editPane;
byte b[]=new byte[118];
Thread thread;
public WinTwo(){
text=new JTextField(20);
editPane=new JEditorPane();
editPane.setEditable(false);
button=new JButton("确定");
thread=new Thread(this);
JPanel p=new JPanel();
p.add(new JLabel("输入网址:"));
p.add(text);
p.add(button);
Container con=getContentPane();
con.add(new JScrollPane(editPane),BorderLayout.CENTER);
con.add(p,BorderLayout.NORTH);
setBounds(60,60,360,300);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
editPane.addHyperlinkListener(new HyperlinkListener(){
public void hyperlinkUpdate(HyperlinkEvent e){
if(e.getEventType()==HyperlinkEvent.EventType.ACTIVATED){
try{editPane.setPage(e.getURL());}
catch(IOException e1){editPane.setText(""+e1);}
}
}});
}
public void actionPerfomed(ActionEvent e){
if(!(thread.isAlive()))
thread=new Thread(this);
try{thread.start();}
catch(Exception ee){text.setText("正在读取"+url);}
}
public void run(){
try { int n=-1;
editPane.setText(null);
url=new URL(text.getText().trim());
editPane.setPage(url);
}
catch(MalformedURLException e1){
text.setText(""+e1);
return;
}
catch(IOException e1){
text.setText(""+e1);
return;
}
}
} 展开
3个回答
展开全部
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import javax.swing.event.*;
public class llq{
public static void main(String args[]){
new WinTwo();
}
}
class WinTwo extends JFrame implements ActionListener,Runnable{
JButton button;
URL url;
JTextField text;
JEditorPane editPane;
byte b[]=new byte[118];
Thread thread;
public WinTwo(){
text=new JTextField(20);
editPane=new JEditorPane();
editPane.setEditable(false);
button=new JButton("确定");
thread=new Thread(this);
JPanel p=new JPanel();
p.add(new JLabel("输入网址:"));
p.add(text);
p.add(button);
Container con=getContentPane();
con.add(new JScrollPane(editPane),BorderLayout.CENTER);
con.add(p,BorderLayout.NORTH);
setBounds(60,60,360,300);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
editPane.addHyperlinkListener(new HyperlinkListener(){
public void hyperlinkUpdate(HyperlinkEvent e){
if(e.getEventType()==HyperlinkEvent.EventType.ACTIVATED){
try{editPane.setPage(e.getURL());}
catch(IOException e1){editPane.setText(""+e1);}
}
}});
}
///////////////////////////////下面这行掉了个r////////////////////////
//public void actionPerformed(ActionEvent e){
public void actionPerfomed(ActionEvent e){
if(!(thread.isAlive()))
thread=new Thread(this);
try{thread.start();}
catch(Exception ee){text.setText("正在读取"+url);}
}
public void run(){
try { int n=-1;
editPane.setText(null);
url=new URL(text.getText().trim());
editPane.setPage(url);
}
catch(MalformedURLException e1){
text.setText(""+e1);
return;
}
catch(IOException e1){
text.setText(""+e1);
return;
}
}
}
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import javax.swing.event.*;
public class llq{
public static void main(String args[]){
new WinTwo();
}
}
class WinTwo extends JFrame implements ActionListener,Runnable{
JButton button;
URL url;
JTextField text;
JEditorPane editPane;
byte b[]=new byte[118];
Thread thread;
public WinTwo(){
text=new JTextField(20);
editPane=new JEditorPane();
editPane.setEditable(false);
button=new JButton("确定");
thread=new Thread(this);
JPanel p=new JPanel();
p.add(new JLabel("输入网址:"));
p.add(text);
p.add(button);
Container con=getContentPane();
con.add(new JScrollPane(editPane),BorderLayout.CENTER);
con.add(p,BorderLayout.NORTH);
setBounds(60,60,360,300);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
editPane.addHyperlinkListener(new HyperlinkListener(){
public void hyperlinkUpdate(HyperlinkEvent e){
if(e.getEventType()==HyperlinkEvent.EventType.ACTIVATED){
try{editPane.setPage(e.getURL());}
catch(IOException e1){editPane.setText(""+e1);}
}
}});
}
///////////////////////////////下面这行掉了个r////////////////////////
//public void actionPerformed(ActionEvent e){
public void actionPerfomed(ActionEvent e){
if(!(thread.isAlive()))
thread=new Thread(this);
try{thread.start();}
catch(Exception ee){text.setText("正在读取"+url);}
}
public void run(){
try { int n=-1;
editPane.setText(null);
url=new URL(text.getText().trim());
editPane.setPage(url);
}
catch(MalformedURLException e1){
text.setText(""+e1);
return;
}
catch(IOException e1){
text.setText(""+e1);
return;
}
}
}
追问
你好厉害哈,我先问下你学java多久了?到什么程度了?调这个程序用了多长时间啊!我刚学java,上面这个是书本例题,你帮忙调出来了,可是好像不显示网页啊,为什么??
展开全部
咱一两个类,可弄不了这个,呵呵呵.!
想给你粘贴个参考资料,还不行!!!!
参考以下这个
http://topic.csdn.net/t/20050522/19/4026943.html
希望对你有帮助
http://topic.csdn.net/u/20100427/01/13aabe17-c6be-47e1-a3aa-67955101d0af.html
想给你粘贴个参考资料,还不行!!!!
参考以下这个
http://topic.csdn.net/t/20050522/19/4026943.html
希望对你有帮助
http://topic.csdn.net/u/20100427/01/13aabe17-c6be-47e1-a3aa-67955101d0af.html
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
按钮的事件没有添加
追问
谢谢
追答
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import javax.swing.event.*;
public class llq{
public static void main(String args[]){
new WinTwo();
}
}
class WinTwo extends JFrame implements ActionListener,Runnable{
JButton button;
URL url;
JTextField text;
JEditorPane editPane;
byte b[]=new byte[118];
Thread thread;
public WinTwo(){
text=new JTextField(20);
editPane=new JEditorPane();
editPane.setEditable(false);
button=new JButton("确定");
thread=new Thread(this);
JPanel p=new JPanel();
p.add(new JLabel("输入网址:"));
p.add(text);
p.add(button);
Container con=getContentPane();
con.add(new JScrollPane(editPane),BorderLayout.CENTER);
con.add(p,BorderLayout.NORTH);
setBounds(60,60,360,300);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
editPane.addHyperlinkListener(new HyperlinkListener(){
public void hyperlinkUpdate(HyperlinkEvent e){
if(e.getEventType()==HyperlinkEvent.EventType.ACTIVATED){
try{editPane.setPage(e.getURL());}
catch(IOException e1){editPane.setText(""+e1);}
}
}});
}
//也可以添加其他的事件
public void actionPerfomed(ActionEvent e){
if(!(thread.isAlive()))
thread=new Thread(this);
try{thread.start();}
catch(Exception ee){text.setText("正在读取"+url);}
}
public void run(){
try { int n=-1;
editPane.setText(null);
url=new URL(text.getText().trim());
editPane.setPage(url);
}
catch(MalformedURLException e1){
text.setText(""+e1);
return;
}
catch(IOException e1){
text.setText(""+e1);
return;
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询