package Txt;
import java.awt.AWTEvent;
import java.awt.AWTException;
import java.awt.Color;
import java.awt.Font;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.AWTEventListener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowEvent;
import java.awt.event.WindowFocusListener;
import java.awt.event.WindowStateListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.swing.ButtonGroup;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JToolBar;
import javax.swing.KeyStroke;
import javax.swing.ListSelectionModel;
import javax.swing.filechooser.FileFilter;
public class SearchText implements ActionListener, WindowFocusListener,AWTEventListener,
Runnable{
static JFrame searchFrame = new JFrame();
JDialog dialog = new JDialog(searchFrame, "设置");
JPanel jpanel = new JPanel();
JPanel typePanel = new JPanel();
JPanel radioButtonPanel = new JPanel();
JPanel sizePanel = new JPanel();
JPanel buttonPanel = new JPanel();
JLabel wordLabel = new JLabel("关键字:");
JLabel fileLabel = new JLabel("搜索范围:");
static JLabel statusBar = new JLabel();
JLabel notMoreThanLabel=new JLabel("不大于:");
JLabel notLessThanLabel=new JLabel("不小于:");
JLabel mKbLabel=new JLabel("KB");
JLabel lKbLabel=new JLabel("KB");
static JTextField wordField = new JTextField();
static JTextField notMoreThanField=new JTextField();
static JTextField notLessThanField=new JTextField();
static DefaultListModel listModel = new DefaultListModel();
static JList fileList = new JList(listModel);
JTabbedPane tabbed = new JTabbedPane();
JToolBar toolBar = new JToolBar();
static JTextArea resultArea = new JTextArea();
JTextArea typeArea=new JTextArea();
JButton chooseDialog = new JButton("选择");
JButton addFileDialog = new JButton("添加");
JButton searchButton = new JButton("搜索");
JButton stopButton = new JButton("停止");
JButton setButton = new JButton("设置");
JButton aboutButton = new JButton("关于");
JButton exitButton = new JButton("退出");
JButton helpButton=new JButton("帮助");
JButton saveButton = new JButton("保存设置");
JButton cancelButton = new JButton("取消");
static JScrollPane areaJsp = new JScrollPane(resultArea);
static JScrollPane listJsp = new JScrollPane(fileList);
JScrollPane typeJsp = new JScrollPane(typeArea);
JPopupMenu textMenu=new JPopupMenu();
JPopupMenu listMenu=new JPopupMenu();
JMenuItem mCopy=new JMenuItem("复制");
JMenuItem mResultToSearch=new JMenuItem("结果转为搜索范围");
JMenuItem mDel=new JMenuItem("删除");
JFileChooser fileChooser =new JFileChooser();
ButtonGroup radioGroup = new ButtonGroup();
JRadioButton caseRadioButton = new JRadioButton("区分大小写");
JRadioButton unCaseRadioButton = new JRadioButton("不区分大小写");
static Set<File> fileSet=new HashSet<File>();
int mount = 0;
static float notMoreThanValue=5120;
static float notLessThanValue=0;
static List<String> fileType=new ArrayList<String>();
static List<String> unfileType=new ArrayList<String>();
static Toolkit toolkit=Toolkit.getDefaultToolkit();
Clipboard clip=toolkit.getSystemClipboard();
static List<String> pathList=new ArrayList<String>();
boolean stopSearch=false;
static boolean allTypes=false;
boolean caseIsSelect = false, unCaseIsSelect = true;
boolean ctrlIsDown=false,enterIsDown=false;
static boolean startSearch=false;
long startTime;
public void init() {
searchFrame.setTitle("一键搜索");
searchFrame.setSize(390, 405);
searchFrame.setLocationRelativeTo(null);
searchFrame.setResizable(false);
searchFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
dialog.setSize(250, 235);
dialog.setLayout(null);
dialog.setResizable(false);
dialog.setLocationRelativeTo(null);
dialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
Font txtFont = new Font("宋体", Font.PLAIN, 14);
Font buttonFont = new Font("宋体", Font.PLAIN, 12);
jpanel.setBackground(Color.white);
jpanel.setLayout(null);
typePanel.setLayout(null);
radioButtonPanel.setLayout(null);
sizePanel.setLayout(null);
buttonPanel.setLayout(null);
toolBar.setFloatable(false);
wordLabel.setBounds(20, 10, 60, 30);
fileLabel.setBounds(5, 50, 70, 30);
notMoreThanLabel.setBounds(45, 20, 60, 30);
notLessThanLabel.setBounds(45, 70, 60, 30);
notMoreThanField.setBounds(100, 25, 70, 20);
notLessThanField.setBounds(100, 75, 70, 20);
mKbLabel.setBounds(175, 20, 60, 30);
lKbLabel.setBounds(175, 70, 60, 30);
wordField.setBounds(70, 15, 240, 20);
toolBar.setBounds(0, 355, 390, 20);
listJsp.setBounds(70, 55, 240, 80);
typeJsp.setBounds(10,10,220,100);
chooseDialog.setBounds(320, 55, 60, 20);
addFileDialog.setBounds(320, 85, 60, 20);
searchButton.setBounds(6, 140, 60, 25);
stopButton.setBounds(85, 140, 60, 25);
setButton.setBounds(163, 140, 60, 25);
aboutButton.setBounds(241, 140, 60, 25);
exitButton.setBounds(319, 140, 60, 25);
helpButton.setBounds(160,115,60,20);
saveButton.setBounds(25, 175, 85, 25);
cancelButton.setBounds(160, 175, 60, 25);
tabbed.setBounds(0, 0, 250, 170);
areaJsp.setBounds(0, 170, 385, 185);
caseRadioButton.setBounds(65, 30, 100, 25);
unCaseRadioButton.setBounds(65, 70, 110, 25);
wordLabel.setFont(txtFont);
notMoreThanLabel.setFont(txtFont);
notLessThanLabel.setFont(txtFont);
mKbLabel.setFont(new Font("楷体",Font.PLAIN,12));
lKbLabel.setFont(new Font("楷体",Font.PLAIN,12));
fileLabel.setFont(txtFont);
statusBar.setFont(buttonFont);
wordField.setFont(txtFont);
notMoreThanField.setFont(txtFont);
notLessThanField.setFont(txtFont);
chooseDialog.setFont(buttonFont);
addFileDialog.setFont(buttonFont);
searchButton.setFont(buttonFont);
stopButton.setFont(buttonFont);
setButton.setFont(buttonFont);
aboutButton.setFont(buttonFont);
exitButton.setFont(buttonFont);
saveButton.setFont(buttonFont);
helpButton.setFont(buttonFont);
cancelButton.setFont(buttonFont);
resultArea.setFont(buttonFont);
typeArea.setFont(txtFont);
typeArea.setText(".java,.txt");
notMoreThanField.setText(""+notMoreThanValue);
notLessThanField.setText(""+notLessThanValue);
this.addTypeWords();
toolkit.addAWTEventListener(new SearchText(), KeyEvent.KEY_EVENT_MASK);
unCaseRadioButton.setSelected(true);
resultArea.setEditable(false);
typeArea.setWrapStyleWord(true);
typeArea.setLineWrap(true);
stopButton.setEnabled(false);
fileChooser.setMultiSelectionEnabled(true);
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
fileChooser.setFileFilter(new TxtFileFilter());
fileList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
mCopy.setMnemonic('C');
mCopy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,InputEvent.CTRL_DOWN_MASK));
mResultToSearch.setMnemonic('G');
mResultToSearch.setAccelerator(Key
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
File_快速搜索.rar (12个子文件)
File_快速搜索
bin
Txt
SearchText.class 21KB
SearchText$2.class 1KB
SearchText$1.class 941B
SearchText$TxtFileFilter.class 2KB
META-INF
MANIFEST.MF 51B
.settings
org.eclipse.jdt.core.prefs 629B
src
Txt
SearchText.java 21KB
META-INF
MANIFEST.MF 51B
一键搜索.jar 14KB
.project 500B
一键搜索.jar 14KB
.classpath 232B
共 12 条
- 1
资源评论
xz296450284
- 粉丝: 3
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功