运行时的图片如下:
下面是代码.
/*
* Test4.java
*
* Created on 2007年9月27日, 下午3:05
*/
package test2;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;
/**
*
* @author hadeslee
*/
public class Test4 extends javax.swing.JFrame {
private Task task; //只存在的一个方法
/** Creates new form Test4 */
public Test4() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception exe) {
exe.printStackTrace();
}
initComponents();
jpb.setStringPainted(true);
jpb.setVisible(false);
this.setLocationRelativeTo(null);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
//
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
input = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
output = new javax.swing.JTextArea();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jpb = new javax.swing.JProgressBar();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("查看网页源文件");
setResizable(false);
jLabel1.setForeground(new java.awt.Color(51, 51, 255));
jLabel1.setText("地址");
input.setForeground(new java.awt.Color(51, 51, 255));
input.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
inputActionPerformed(evt);
}
});
jButton1.setForeground(new java.awt.Color(51, 51, 255));
jButton1.setText("查看");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jScrollPane1.setBorder(javax.swing.BorderFactory.createTitledBorder("源文件"));
output.setColumns(20);
output.setEditable(false);
output.setLineWrap(true);
output.setRows(5);
output.setWrapStyleWord(true);
jScrollPane1.setViewportView(output);
jButton2.setText("保存");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setText("退出");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {

