因为eclipse上没有matisse form,所以不好再次修改我上次写的图形界面,所以呢,下了个Myeclipse,使用matisse form重新写了下此爬虫的GUI。
主要代码 :
/*
* scs.java
*
* Created on __DATE__, __TIME__
*/
package cd.ccx;
import java.awt.TextArea;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.awt.TextComponent;
import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.Mongo;
import com.mongodb.MongoException;
/**
*
* @author __USER__
*/
public class scs extends javax.swing.JFrame {
public StringBuffer Download_link = new StringBuffer();
/** Creates new form scs */
public scs() {
initComponents();
}
//GEN-BEGIN:initComponents
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
button1 = new java.awt.Button();
label1 = new java.awt.Label();
button2 = new java.awt.Button();
button3 = new java.awt.Button();
textArea1 = new java.awt.TextArea();
label2 = new java.awt.Label();
textField1 = new java.awt.TextField();
button4 = new java.awt.Button();
label3 = new java.awt.Label();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
button1.setLabel("\u5f00\u59cb\u722c\u866b :");
button1.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent arg0) {
String command_start="cmd /k start cmd.bat";
//E:\\scrapy---测试用2\\GitHub\\ scrapy crawl github";
Runtime r=Runtime.getRuntime();
try {
Process ps=r.exec(command_start);
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
});
label1.setText("Scrapy crawl github");
button2.setLabel("\u7ed3\u675f\u722c\u866b :");
button2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
Runtime.getRuntime().exec("TaskKill /IM cmd.exe");
} catch (IOException e1) {
// TODO 自动生成的 catch 块
e1.printStackTrace();
}
}
});
button3.setLabel("\u4ece\u6570\u636e\u5e93\u4e2d\u83b7\u53d6\u4fe1\u606f :");
button3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
button3ActionPerformed(evt);
}
});
label2.setText("\u8f93\u5165\u4f60\u60f3\u4e0b\u8f7d\u7684\u9879\u76ee\uff08\u7528\u6237/\u9879\u76ee\u540d\uff09 :");
textField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
//textField1.setText("gh");
}
});
button4.setLabel("\u4e0b\u8f7d!...");
//final String tf=textField1.getText();
/*button4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String tf=tex