请看下面的java代码

来源:百度知道 编辑:UC知道 时间:2024/06/28 10:49:44
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import javax.swing.JEditorPane;
public class url
{
public static void main(String args[])
{
new NetWin();
}
}
class NetWin extends Frame implements ActionListener,Runnable
{
Button button;
TextArea area;
Label label;
TextField text;
Thread thread;
URL murl;
JEditorPane editPane;
byte b[]=new byte[118];
NetWin()
{
button=new Button("确定");
area=new TextArea(12,12);
label=new Label("输入网址");
text=new TextField(20);
thread=new Thread(this);
button.addActionListener(this);
Panel p=new Panel();
editPane=new JEditorPane();
editPane.setEditable(false);
p.add(label);
p.add(text);
p.add(button);
ScrollPane scroll=new ScrollPane();
scroll.add(editPane);
add(scroll,Bor

编译正常
可以运行,
运行显示表单窗口,要求输入URL
输入URL格式为www.sohu.com 出错
java.net.MalformedURLException: no protocol: www.sohu.com/

输入URL格式为http://www.sohu.com

显示搜狐首页内容
只是版面有些乱。

不知你要干什么,有什么问题

在输入网址后,出现
java.net.MalformedURLException: no protocol: www.baidu.com
-----------------------------------------
关注此问题,很有意思啊~