⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 searchdialog.java

📁 模拟实现对windows的记事本多线程查找
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class SearchDialog extends Dialog implements ActionListener{
	public static JLabel lab1 = new JLabel("查找字符串");
	public static JLabel lab2 = new JLabel("查找字符串");
	public static TextField text1 = new TextField(10);
	public static TextField text2 = new TextField(10);
	public static JButton btn = new JButton("搜索");
	public static JTextArea ta;
	public String str1,str2;
	public Thread searchA = new Thread(new Search(text1));
	public Thread searchB = new Thread(new Search(text2));
	public SearchDialog(FileDialogDemo owner ,JTextArea ta){
		super(owner,"搜索",false);
		this.ta = ta;
		text1.setText("");
		text2.setText("");
		str1="";
		str2="";
		setLayout(null);
		lab1.setBounds(10,30,80,20);
		text1.setBounds(90, 30, 90, 20);
		lab2.setBounds(10,70,80,20);
		text2.setBounds(90,70,90,20);
		btn.setBounds(190,40,80,40);
		add(lab1);
		add(lab2);
		add(text1);
		add(text2);
		add(btn);
		setResizable(false);
		btn.addActionListener(this);
		class TextHandler implements TextListener{
			public void textValueChanged(TextEvent e){
				str1 = text1.getText();
				str2 = text2.getText();
			}
		}
		text1.addTextListener(new TextHandler());
		text2.addTextListener(new TextHandler());
	}
	public void actionPerformed(ActionEvent e){
		if(e.getSource() == btn){
			searchA.start();
			searchB.start();
			SearchDialog.this.dispose();
		}
	}
	public void showFind(){
		setBounds(350,350,280,110);
		setVisible(true);
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -