📄 checklinks.java
字号:
import java.awt.*;
import javax.swing.*;
import java.net.*;
import java.io.*;
import java.util.*;
public class CheckLinks extends JFrame {
JLabel label1 = new JLabel();
JLabel label2=new JLabel();
JLabel label3=new JLabel();
JLabel label4=new JLabel();
JLabel label5=new JLabel();
JLabel lblStartTime=new JLabel();
JLabel lblProcessTime=new JLabel();
JLabel lblProcessSpeed=new JLabel();
JButton begin = new JButton();
JTextField url = new JTextField("http://google.com");
Choice chcDepth=new Choice();
JTextField txtFileType=new JTextField("text/");
Choice chcFileSize=new Choice();
JScrollPane errorScroll =new JScrollPane();
JScrollPane inUrlScroll =new JScrollPane();
JScrollPane ioutUrlScroll =new JScrollPane();
JTextArea inURL=new JTextArea();
JTextArea outURL=new JTextArea();
JTextArea errors = new JTextArea();
JLabel current = new JLabel();
JLabel inUrlLinksLabel=new JLabel();
JLabel outUrlLinksLabel=new JLabel();
JLabel goodLinksLabel = new JLabel();
JLabel badLinksLabel = new JLabel();
protected Thread backgroundThread;
protected URL base;
protected int intWebDepth=0;
protected int intWebSize=0;
protected String strWebType;
protected int intInUrl=0;
protected int intOutUrl=0;
protected int badLinksCount = 0;
protected int goodLinksCount = 0;
protected int intStartTime;
protected int intNowTime;
protected int intProcessTime;
protected float fltN=100f;
protected String strStartTime;
protected Collection ErrorUrl = new ArrayList(3);
protected Collection InUrl = new ArrayList(3);
protected Collection OutUrl = new ArrayList(3);
protected Collection UrlCollection = new ArrayList(3);
public CheckLinks()
{
//{{INIT_CONTROLS
setTitle(" check link");
getContentPane().setLayout(null);
setSize(405,650);
setVisible(false);
label1.setText("Enter a URL:");
getContentPane().add(label1);
label1.setBounds(12,12,84,12);
label2.setText("For example: http//www.scut.edu.cn");
getContentPane().add(label2);
label2.setBounds(108,12,288,12);
begin.setText("Begin");
begin.setActionCommand("Begin");
getContentPane().add(begin);
begin.setBounds(12,36,84,24);
getContentPane().add(url);
url.setBounds(108,36,288,24);
label3.setText("Depth");
getContentPane().add(label3);
label3.setBounds(12,65,35,20);
chcDepth.add(" 20 ");
chcDepth.add(" 30 ");
chcDepth.add(" 40 ");
chcDepth.add(" 50 ");
chcDepth.add(" 60 ");
getContentPane().add(chcDepth);
chcDepth.setBounds(53,65,60,20);
label4.setText("FileType");
getContentPane().add(label4);
label4.setBounds(123,65,70,20);
getContentPane().add(txtFileType);
txtFileType.setBounds(194,65,50,20);
label5.setText("FileSize");
getContentPane().add(label5);
label5.setBounds(255,65,70,20);
chcFileSize.add("40 K");
chcFileSize.add("50 K");
chcFileSize.add("60 K");
chcFileSize.add("20 K");
chcFileSize.add("30 K");
getContentPane().add(chcFileSize);
chcFileSize.setBounds(326,65,55,20);
lblStartTime.setText("StartTime:"+strStartTime);
getContentPane().add(lblStartTime);
lblStartTime.setBounds(12,87,330,12);
current.setText("Currently Processing: ");
getContentPane().add(current);
current.setBounds(12,105,384,12);
badLinksLabel.setText("Bad Links: 0");
getContentPane().add(badLinksLabel);
badLinksLabel.setBounds(12,123,192,12);
goodLinksLabel.setText("Good Links: 0");
getContentPane().add(goodLinksLabel);
goodLinksLabel.setBounds(220,123,192,12);
errorScroll.setAutoscrolls(true);
errorScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
errorScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
errorScroll.setOpaque(true);
getContentPane().add(errorScroll);
errorScroll.setBounds(12,140,384,146);
errors.setEditable(false);
errorScroll.getViewport().add(errors);
errors.setBounds(0,0,366,138);
lblProcessTime.setText("ProcessTime:0");
getContentPane().add(lblProcessTime);
lblProcessTime.setBounds(12,292,150,12);
lblProcessSpeed.setText("ProcessSpeed:0");
getContentPane().add(lblProcessSpeed);
lblProcessSpeed.setBounds(190,292,150,12);
inUrlLinksLabel.setText("inUrlLinks: 0");
getContentPane().add(inUrlLinksLabel);
inUrlLinksLabel.setBounds(12,309,192,12);
inUrlScroll.setAutoscrolls(true);
inUrlScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
inUrlScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
inUrlScroll.setOpaque(true);
getContentPane().add(inUrlScroll);
inUrlScroll.setBounds(12,325,384,146);
inURL.setEditable(false);
inUrlScroll.getViewport().add(inURL);
inURL.setBounds(0,0,366,138);
outUrlLinksLabel.setText("outUrlLinks: 0");
getContentPane().add(outUrlLinksLabel);
outUrlLinksLabel.setBounds(12,476,192,12);
ioutUrlScroll.setAutoscrolls(true);
ioutUrlScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
ioutUrlScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
ioutUrlScroll.setOpaque(true);
getContentPane().add(ioutUrlScroll);
ioutUrlScroll.setBounds(12,492,384,146);
outURL.setEditable(false);
ioutUrlScroll.getViewport().add(outURL);
outURL.setBounds(0,0,366,138);
}}
SymAction lSymAction = new SymAction();
begin.addActionListener(lSymAction);
}
static public void main(String args[])
{
(new CheckLinks()).setVisible(true);
}
public void addNotify()
{
Dimension size = getSize();
super.addNotify();
if ( frameSizeAdjusted )
return;
frameSizeAdjusted = true;
Insets insets = getInsets();
javax.swing.JMenuBar menuBar = getRootPane().getJMenuBar();
int menuBarHeight = 0;
if ( menuBar != null )
menuBarHeight = menuBar.getPreferredSize().height;
setSize(insets.left + insets.right + size.width, insets.top +
insets.bottom + size.height +
menuBarHeight);
}
class SymAction implements java.awt.event.ActionListener {
public void actionPerformed(java.awt.event.ActionEvent event)
{
Object object = event.getSource();
if ( object == begin ){
strStartTime=(new Date()).toString();
intStartTime=(new Date()).getHours()*3600+(new Date()).getMinutes()*60+(new Date()).getSeconds();
begin_actionPerformed(event);
intWebDepth=chcDepth.getSelectedIndex();
intWebSize=chcFileSize.getSelectedIndex();
strWebType=txtFileType.getText();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -