写的程序如下,调试老是有如下的错误:
E:\java\example\net\Http\HTTPBrowser\HTTPBrowser.java:16: <identifier> expecte
d
jbt.addActionListener(actionListener);
                             ^
1 error程序如下:
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import javax.swing.*;
import javax.swing.text.DefaultStyledDocument;public class HTTPBrowser extends JFrame {
JTextField jtfAddress = new JTextField(20);
JTextPane jtpShow = new JTextPane();
JTextArea jtaSource = new JTextArea();
JButton jbt = new JButton("connect");
ActionListener actionListener = new ShowHTMLListener();
jbt.addActionListener(actionListener); public HTTPBrowser()
{
Container container = getContentPane();
JPanel p1 = new JPanel();
p1.add(new JLabel("地址"));
p1.add(jtfAddress);
p1.add(jbt);
JSplitPane spane = new JSplitPane();
spane.add(new JScrollPane(jtpShow), JSplitPane.TOP);
spane.add(new JScrollPane(jtaSource), JSplitPane.BOTTOM);
spane.setDividerLocation(130);
spane.setDividerSize(2);

container.add(p1, BorderLayout.NORTH);
container.add(spane, BorderLayout.CENTER);
setSize(WIDTH, HEIGHT);
} class ShowHTMLListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
try
{
URL address = new URL(jtfAddress.getText());
jtpShow.setContentType("text/html");
jtpShow.setPage(address);
BufferedReader in = new BufferedReader(new InputStreamReader
(address.openStream()));
String line;
StringBuffer content = new StringBuffer();
while((line = in.readLine()) != null)
{
content.append(line + "\n");
}
jtaSource.setText(new String(content));
in.close();

}
catch(Exception e)
{
e.printStackTrace();
}
}
}
public static void main(String[] args) {
// TODO: Add your code here
HTTPBrowser httpBrowser = new HTTPBrowser();
httpBrowser.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
httpBrowser.setVisible(true);
}

private int WIDTH = 300;
private int HEIGTH = 400;
}