当前位置:网站首页>A simple file searcher
A simple file searcher
2022-06-25 20:40:00 【As high as the wind】
1、 Interface

As soon as you see this interface, the form is an empty layout , The interface is actually very simple, a text input box 、 Buttons and text entry fields
2、 function
Button monitoring , Click this button to list all the sub files under the path folder
3、 Specific code :
package FileSreach;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
/**
* Interface
* @author Administrator
*
*/
public class FileSreachFrame extends JFrame implements ActionListener{
private static final long serialVersionUID = 1L;
private JTextArea jta;
private JTextField jtf;
public static void main(String[] args){
new FileSreachFrame().initSreachFrame();
}
private void initSreachFrame(){
this.setSize(500,500);
this.setTitle(" File searcher ");
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(false);
this.setLayout(null);
jtf = new JTextField();
jtf.setBounds(50,25,250,35);
JButton button = new JButton(" Begin your search ");
button.setBounds(350,25,100,35);
button.addActionListener(this);
jta = new JTextArea();
JScrollPane jsp = new JScrollPane(jta);
jsp.setBounds(50,125,400,300);
this.add(jtf);
this.add(button);
this.add(jsp);
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getActionCommand().equals(" Begin your search ")){
FileSreachFunction sreach = new FileSreachFunction(jtf,jta);
// jta.removeAll();
// FileSreachFrame.this.repaint();
}
}
}
package FileSreach;
import java.io.File;
import javax.swing.JTextArea;
import javax.swing.JTextField;
/**
* Realization
* @author Administrator
*
*/
public class FileSreachFunction {
private JTextArea jta;
public FileSreachFunction(JTextField jtf,JTextArea jta){
this.jta = jta;
this.initSreachFunction(jtf.getText());
}
private void initSreachFunction(String path){
File file = new File(path);
if(file.exists()&&file.length()!=0){
if(file.isFile()){
jta.append(file.getAbsolutePath()+"\r\n");
}else{
File[] files = file.listFiles();
for (int i = 0; i < files.length; i++) {
String absolute = files[i].getAbsolutePath();
jta.append(absolute+"\r\n");
this.initSreachFunction(absolute);
}
}
}
}
}
边栏推荐
- Nnformer reading notes
- How does zhiting home cloud and home assistant access homekit respectively? What is the difference between them?
- Sonar series: continuous scanning through Jenkins integrated sonarqube (IV)
- Yunzhisheng atlas supercomputing platform: computing acceleration practice based on fluid + alluxio (Part 2)
- MySQL lock
- This is a simple and cool way to make large screen chart linkage. Smartbi will teach you
- 8 minutes to understand the wal mechanism of tdengine
- COMP9024
- [harmonyos] [arkui] how can Hongmeng ETS call pa
- Live broadcast preview | front line experts invite you to talk: the value of data science enabling multiple application scenarios
猜你喜欢
laf. JS - open source cloud development framework (readme.md)
Instant aesthetics of the Centennial Olympic Games: beauty in the air, condensed in minutes and seconds - Alibaba cloud video cloud AI editorial department "cloud smart scissors"

Splunk series: Splunk installation and deployment (I)

Intra domain information collection for intranet penetration

Lantern Festival, learning at the right time! Novice training camp attacks again, learning buff continues to fill up
Uncover n core 'black magic' of Presto + alluxio

Transunet reading notes
[data recovery in North Asia] a data recovery case in which the upper virtual machine data is lost due to the hard disk failure and disconnection of raid6 disk array

Impact of Huawei application transfer and application claim on user identification

Li-rads lesion classification reading notes
随机推荐
Great changes in the interaction between people and the digital world
Corporate finance formula_ P1_ Accounting statement and cash flow
Introduction to event flow, event capture, and event bubbling
H5 application conversion fast application
HMS core actively explores the function based on hardware ear return, helping to reduce the overall singing delay rate of the singing bar by 60%
Tencent music knowledge map search practice
Lantern Festival, learning at the right time! Novice training camp attacks again, learning buff continues to fill up
CiteSpace download installation tutorial
Record some questions about MySQL (DNS reverse resolution in Linux)
The last core step of configuring theano GPU
An unusual interview question: why doesn't the database connection pool adopt IO multiplexing?
2022 oceanbase technical essay contest officially opened | come and release your force
Png to NII
Share a billing system (website) I have developed
Baidu AI Financing Innovation workshop enrollment!
Robotium_ (clickbyid method)
Cvpr2019 | the latest cvpr2019 papers are the first to read!
Introduction to interface test, interface protocol and common interface test tools
Node connection MySQL
JS canvas drawing an arrow with two hearts