工作中我们经常为了找一个文件而耗费大半天的时间
如果用系统自带的搜索功能太慢了,于是我自己写了一个文件管理的工具
也是经过了我的实际使用,效果还不错所以分享一下!
保存文件方便,搜索也快,最后如果文件移动到了别的位置,还是可以秒搜
备份数据库,同步文件都包含在里面了
下面是javaswing界面:

javaswing文件管理界面
功能简单说明
1.首先我们先创建一个根目录,这个根目录以后就一直用来保存我们的文件
2.然后当我们保存一个文件的时候,先复制这个文件,然后点击"剪贴板路径"
这时会把剪贴板复制的文件的路径添加到文件路径文本框中如下图
(点击查看gif动态演示):

保存文件.gif
最后搜索的关键字默认会以文件名,也可以另外添加关键字,用于搜索这个文件
3.保存文件
这里把文件uuid重命名了,然后把文件uuid名和原文件名,以及搜索关键字保存
到数据库表中,这里简单创建一个表用来保存文件信息
CREATE TABLE my_files (
id int(32) NOT NULL AUTO_INCREMENT,
file_name varchar(100) NOT NULL,
fileUUID varchar(100) NOT NULL,
keywords varchar(255) NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
4.快速搜索文件
(点击查看gif动态演示):

点击原文件名那一栏时可以快速定位到文件的目录
如果点击uuid路径一栏则复制文件到剪贴板上
(点击查看gif动态演示):

复制文件.gif
5.最后下面是源码,不足这处欢迎指正
/**
*
*/
package com.cn.swing;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import java.awt.Color;
import javax.swing.JButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import org.apache.commons.io.FileUtils;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import com.cn.entity.MyFiles;
import com.cn.entity.MyFilesExample;
import com.cn.mapper.MyFilesMapper;
import com.cn.utils.FileUtilsUpdate;
import com.cn.utils.MysqlUtils;
import com.cn.utils.PropertiesUtils;
import com.cn.utils.RobotUtils;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import java.util.UUID;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
/**
* @Title: FileCommand.java
* @Description:
* @author 圣光帕拉丁
* @date 2021-04-10 05:07:53
*/
public class FileCommand extends JFrame {
private JPanel contentPane;
private JTable table;
private JTextField text_filepath;
private JTextField text_keywords;
private JTextField textField_2;
private JTextField text_id;
private JTextField text_basePath;
private SqlSessionFactory sqlSessionFactory;
private JButton button;
private JButton button_1;
private JButton button_2;
private JButton button_3;
private JButton button_5;
private JButton button_6;
private JTextField updateFilePath;
public SqlSessionFactory getSqlSessionFactory() {
return sqlSessionFactory;
}
public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
this.sqlSessionFactory = sqlSessionFactory;
}
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
final FileCommand frame = new FileCommand();
frame.setVisible(true);
frame.setLocationRelativeTo(null);
//添加图标
ImageIcon imageIcon=new ImageIcon("./图标/复制图标.png");
frame.setIconImage(imageIcon.getImage());
// 设置mapper
String configFile = "mybatis-cfg.xml";
InputStream inputStream;
inputStream = Resources.getResourceAsStream(configFile);
SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
frame.setSqlSessionFactory(sqlSessionFactory);
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
frame.setTitle("数据库连接成功!");
}
}).start();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public FileCommand() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 1164, 534);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
JScrollPane scrollPane = new JScrollPane();
scrollPane.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
}
});
table = new JTable();
table.setForeground(Color.BLACK);
table.setColumnSelectionAllowed(true);
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
//保存所有复制文件的本地路径
String basePath = text_basePath.getText();
int row = table.getSelectedRow();//当前点击的行值
int column = table.getSelectedColumn();//当前点击的列值
//获取对应行和列的值
String valueAt = table.getValueAt(row, column).toString();
System.out.println(column);
if(column==2){//如果是第3列
//获取前面一列的原文件名
String originalFileName=table.getValueAt(row,1).toString();
//从仓库地址复制到复制到桌面上,再复制到剪贴板上
try {
File file = new File(basePath+"A复制文本临时区");
//如果临时区存在在就先删除,再创建文件夹,这样就清空了文件夹防止内容越来越多
if(file.exists()){
FileUtils.deleteDirectory(file);
file.mkdirs();
}
//复制文件到临时区去,并复制文件到剪贴板上
if(new File(basePath,valueAt).isFile()){
FileUtils.copyFile(new File(basePath,valueAt), new File(basePath+"A复制文本临时区\\"+originalFileName));
}else{
FileUtils.copyDirectory(new File(basePath,valueAt), new File(basePath+"A复制文本临时区\\"+originalFileName));
}
RobotUtils.setSysClipboardFile(basePath+"A复制文本临时区\\"+originalFileName);
setTitle(originalFileName+"---复制成功!"+new Date().toLocaleString());
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//File file = new File(basePath,valueAt);
}else if(column==1){//如果是第二列,就定位路径到该文件
String valueAt2 = table.getValueAt(row, column+1).toString();
String path=basePath+valueAt2;
System.out.println(path);
if(new File(path).isDirectory()){
RobotUtils.startFilePath(path);
}else{
RobotUtils.selectFilePath(path);
}
}
}
});
table.setModel(new DefaultTableModel(
new Object[][] {
/*{},*/
},
new String[] {
"\u5E8F\u53F7", "\u539F\u6587\u4EF6\u540D", "uuid\u8DEF\u5F84", "\u641C\u7D22\u5173\u952E\u5B57"
}
) {
boolean[] columnEditables = new boolean[] {
false, false, false, true
};
public boolean isCellEditable(int row, int column) {
return columnEditables[column];
}
});
scrollPane.setViewportView(table);
text_filepath = new JTextField();
text_filepath.setColumns(10);
JLabel label = new JLabel("文件路径:");
JLabel label_1 = new JLabel("搜索关键字 - 并联:");
text_keywords = new JTextField();
text_keywords.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
if(e.getKeyCode()==e.VK_ENTER){
Thread t2 = new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
int index=1;
String endstr="....";
while(true){
if(index%4==1){
endstr=".";
}else if(index %4==2){
endstr="..";
}else if(index%4==3){
endstr="...";
}
setTitle("正在搜索中"+endstr);
index++;
RobotUtils.mydelay(100);
}
}
});
t2.start();
//搜索文件内空
SqlSession openSession = sqlSessionFactory.openSession();
MyFilesMapper mapper = openSession.getMapper(MyFilesMapper.class);
MyFilesExample example = new MyFilesExample();
//获取关键字的文本内空
String text = text_keywords.getText().trim();
List<MyFiles> selectByExample=null;
if(text.length()>0){
//关键字搜索时用 - 连接,用来表示多个条件并联
if(text.contains("-")){
String[] split = text.split("-");
for (String ss : split) {
example.or().andKeywordsLike("%"+ss+"%");
}
}else{
example.createCriteria().andKeywordsLike("%"+text+"%");
}
example.or().andKeywordsLike("%"+text+"%");
selectByExample = mapper.selectByExample(example);
}else{
selectByExample = mapper.selectByExample(null);
}
//System.out.println(selectByExample);
if(selectByExample!=null&&selectByExample.size()>0){
//list转为二维数组
String[][] listToArr = FileCommand.listToArr(selectByExample);
//设置内容到jtable
table.setModel(new DefaultTableModel(
listToArr,
new String[] {
"\u5E8F\u53F7", "\u539F\u6587\u4EF6\u540D", "uuid\u8DEF\u5F84", "\u641C\u7D22\u5173\u952E\u5B57"
}
) {
boolean[] columnEditables = new boolean[] {
false, false, false, true
};
public boolean isCellEditable(int row, int column) {
return columnEditables[column];
}
});
t2.stop();
setTitle("一共查询到"+selectByExample.size()+"条数据"+System.currentTimeMillis());
}else{
t2.stop();
setTitle("未查询到结果!"+System.currentTimeMillis());
table.setModel(new DefaultTableModel(
new String[][]{},
new String[] {
"\u5E8F\u53F7", "\u539F\u6587\u4EF6\u540D", "uuid\u8DEF\u5F84", "\u641C\u7D22\u5173\u952E\u5B57"
}
) {
boolean[] columnEditables = new boolean[] {
false, false, false, true
};
public boolean isCellEditable(int row, int column) {
return columnEditables[column];
}
});
}
}
}
});
text_keywords.setColumns(10);
textField_2 = new JTextField();
textField_2.setColumns(10);
JLabel lblNewLabel = new JLabel("序号id:");
text_id = new JTextField();
text_id.setColumns(10);
text_basePath = new JTextField();
// text_basePath.setText("G:\\文本复制大本营\\");
Properties p = PropertiesUtils.readProperties("message.properties");
String base_path = p.getProperty("base_path");
String update_file_path = p.getProperty("update_file_path");
try {
base_path = new String(base_path.getBytes("iso-8859-1"),"utf-8");
update_file_path = new String(update_file_path.getBytes("iso-8859-1"),"utf-8");
} catch (UnsupportedEncodingException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
text_basePath.setText(base_path);
text_basePath.setColumns(10);
updateFilePath = new JTextField(update_file_path);
updateFilePath.setColumns(10);
JLabel lblNewLabel_1 = new JLabel("本地存放路径");
JLabel label_2 = new JLabel("<==最后也会到这个目录去搜索");
label_2.setForeground(Color.GREEN);
JButton btnid = new JButton("查询id号对应的内容");
btnid.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String id = text_id.getText();
int idInt = Integer.parseInt(id);
//根据id号查询对应的内容
SqlSession openSession = sqlSessionFactory.openSession();
MyFilesMapper mapper = openSession.getMapper(MyFilesMapper.class);
MyFiles myFiles = mapper.selectByPrimaryKey(idInt);
openSession.close();
String arrMyFiles[]={"文件id号:"+myFiles.getId()+"",myFiles.getFileName(),myFiles.getFileuuid(),myFiles.getKeywords()};
//内容显示到jtable中
table.setModel(new DefaultTableModel(
new Object[][] {
arrMyFiles,
},
new String[] {
"\u5E8F\u53F7", "\u539F\u6587\u4EF6\u540D", "uuid\u8DEF\u5F84", "\u641C\u7D22\u5173\u952E\u5B57"
}
) {
boolean[] columnEditables = new boolean[] {
false, false, false, true
};
public boolean isCellEditable(int row, int column) {
return columnEditables[column];
}
});
//显示关键字文本框 的内容
text_keywords.setText(myFiles.getKeywords());
System.out.println(myFiles);
}
});
button = new JButton("添加文件");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//添加文件
//获取所有文本框 的内空
String filePath = text_filepath.getText();//待处理的文件的路径
String keywords = text_keywords.getText();//关键字
String basePath = text_basePath.getText();//复制到目标根路径
String uuid=UUID.randomUUID().toString().replace("-", "");
//生成uuid加后缀的文件名,如果是文件只生成uuid名
File file = new File(filePath);
if(file.exists()){
String suffix="";
if(file.getName().indexOf(".")!=-1){//如果有后缀名
suffix = file.getName().substring(file.getName().lastIndexOf("."));
}
//复制文件到目标文件夹中
try {
if(suffix.equals("")){//调用 复制文件夹方法
FileUtils.copyDirectory(file, new File(basePath,uuid+suffix));
}else{
FileUtils.copyFile(file, new File(basePath,uuid+suffix));
}
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//把信息保存到数据库中
MyFiles myFiles = new MyFiles();
myFiles.setFileName(file.getName());
myFiles.setKeywords(keywords);
myFiles.setFileuuid(uuid+suffix);
SqlSession openSession = sqlSessionFactory.openSession();
MyFilesMapper mapper = openSession.getMapper(MyFilesMapper.class);
int insert = mapper.insert(myFiles);
System.out.println(insert);
openSession.commit();
openSession.close();
setTitle("添加文件"+file.getName()+"成功!"+System.currentTimeMillis());
}
}
});
button_1 = new JButton("修改");
button_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//修改关键字
String textId = text_id.getText();
if(textId!=null&&textId.trim().length()>0){
String keywords = text_keywords.getText();
MyFiles myFiles = new MyFiles();
myFiles.setKeywords(keywords);
myFiles.setId(Integer.parseInt(textId));
//搜索文件内空
SqlSession openSession = sqlSessionFactory.openSession();
MyFilesMapper mapper = openSession.getMapper(MyFilesMapper.class);
int updateByPrimaryKeySelective = mapper.updateByPrimaryKeySelective(myFiles);
openSession.commit();
openSession.close();
setTitle("修改成功了!"+System.currentTimeMillis());
}else{
setTitle("请填写修改的文件id号!"+System.currentTimeMillis());
}
}
});
button_2 = new JButton("搜索关键字");
button_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//搜索文件内空
SqlSession openSession = sqlSessionFactory.openSession();
MyFilesMapper mapper = openSession.getMapper(MyFilesMapper.class);
MyFilesExample example = new MyFilesExample();
//获取关键字的文本内空
String text = text_keywords.getText().trim();
List<MyFiles> selectByExample=null;
if(text.length()>0){
//关键字搜索时用 - 连接,用来表示多个条件并联
if(text.contains("-")){
String[] split = text.split("-");
for (String ss : split) {
example.or().andKeywordsLike("%"+ss+"%");
}
}else{
example.createCriteria().andKeywordsLike("%"+text+"%");
}
example.or().andKeywordsLike("%"+text+"%");
selectByExample = mapper.selectByExample(example);
}else{
selectByExample = mapper.selectByExample(null);
}
//System.out.println(selectByExample);
if(selectByExample!=null&&selectByExample.size()>0){
//list转为二维数组
String[][] listToArr = FileCommand.listToArr(selectByExample);
//设置内容到jtable
table.setModel(new DefaultTableModel(
listToArr,
new String[] {
"\u5E8F\u53F7", "\u539F\u6587\u4EF6\u540D", "uuid\u8DEF\u5F84", "\u641C\u7D22\u5173\u952E\u5B57"
}
) {
boolean[] columnEditables = new boolean[] {
false, false, false, true
};
public boolean isCellEditable(int row, int column) {
return columnEditables[column];
}
});
setTitle("一共查询到"+selectByExample.size()+"条数据"+System.currentTimeMillis());
}else{
setTitle("未查询到结果!"+System.currentTimeMillis());
table.setModel(new DefaultTableModel(
new String[][]{},
new String[] {
"\u5E8F\u53F7", "\u539F\u6587\u4EF6\u540D", "uuid\u8DEF\u5F84", "\u641C\u7D22\u5173\u952E\u5B57"
}
) {
boolean[] columnEditables = new boolean[] {
false, false, false, true
};
public boolean isCellEditable(int row, int column) {
return columnEditables[column];
}
});
}
}
});
button_3 = new JButton("删除");
button_3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//根据id号删除对应的文件和数据库的记录
String id = text_id.getText();
//如果id号为空就直接返回运行
if(id.length()==0||id.trim().length()==0)return;
//获取根路径
String basePath = text_basePath.getText();
//数据库操作对象
SqlSession openSession = sqlSessionFactory.openSession();
MyFilesMapper mapper = openSession.getMapper(MyFilesMapper.class);
MyFiles myFiles = mapper.selectByPrimaryKey(Integer.parseInt(id));
//删除物理文件和数据库的记录
if(myFiles!=null){
String fileuuid = myFiles.getFileuuid();
if(new File(basePath+fileuuid).isFile()){
new File(basePath+fileuuid ).delete();//删除文件
}else{
try {
FileUtils.deleteDirectory(new File(basePath+fileuuid));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
//删除数据库中的记录
int deleteByPrimaryKey = mapper.deleteByPrimaryKey(Integer.parseInt(id));
openSession.commit();
openSession.close();
setTitle("删除文件成功!!"+System.currentTimeMillis());
}
}
});
JButton button_4 = new JButton("清空");
button_4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
text_filepath.setText("");
text_filepath.requestFocus();
}
});
button_5 = new JButton("清空");
button_5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
text_keywords.setText("");
text_keywords.requestFocus();
}
});
JButton btnNewButton = new JButton("剪贴板路径");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String sysClipboardCopyFilePath = RobotUtils.getSysClipboardCopyFilePath();
text_filepath.setText(sysClipboardCopyFilePath);
text_keywords.setText(new File(sysClipboardCopyFilePath).getName());
if(sysClipboardCopyFilePath.equals(""))setTitle("剪贴板没有内容"+System.currentTimeMillis());
}
});
button_6 = new JButton("打开路径");
button_6.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String text = text_basePath.getText();
RobotUtils.startFilePath(text);
}
});
JButton button_7 = new JButton("同步文件到");
button_7.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//这里设置提示在标题中
Thread tt = new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
int i=0;
while(true){
if(i%4==1){
setTitle("正在同步文件中.");
}else if(i%4==2){
setTitle("正在同步文件中..");
}else if(i%4==3){
setTitle("正在同步文件中...");
}else{
setTitle("正在同步文件中.....");
}
i++;
RobotUtils.mydelay(1000);
}
}
});
tt.start();
//获取配置文件路径
Properties p = PropertiesUtils.readProperties("message.properties");
String base_path = p.getProperty("base_path");
String update_file_path = p.getProperty("update_file_path");
try {
base_path=new String(base_path.getBytes("iso-8859-1"),"utf-8");
update_file_path=new String(update_file_path.getBytes("iso-8859-1"),"utf-8");
//同步文件到指定目录
File file1 = new File(base_path);
File file2 = new File(update_file_path);
try {
int doUpdate = FileUtilsUpdate.doUpdate(file1, file2);
tt.stop();
setTitle("同步文件夹完毕,一共同步: "+doUpdate+" 个文件或文件夹");
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
JLabel label_3 = new JLabel("==>");
JButton button_8 = new JButton("备份数据库");
button_8.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
setTitle("正在导出数据...");
}
}).start();
Properties p = PropertiesUtils.readProperties("./message.properties");
String hostIP = p.getProperty("hostIP");
String userName = p.getProperty("userName");
String password = p.getProperty("password");
String savePath = p.getProperty("savePath");
String fileName = p.getProperty("fileName");
String databaseName = p.getProperty("databaseName");
MysqlUtils.backup(hostIP, userName, password, savePath, fileName, databaseName);
setTitle("导出数据库资源成功!=="+System.currentTimeMillis());
}
});
GroupLayout gl_contentPane = new GroupLayout(contentPane);
gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(100)
.addComponent(textField_2, GroupLayout.PREFERRED_SIZE, 215, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap()
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING, false)
.addComponent(lblNewLabel_1, GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE)
.addComponent(label_1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(label, GroupLayout.PREFERRED_SIZE, 74, GroupLayout.PREFERRED_SIZE))
.addComponent(lblNewLabel))
.addGap(65)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING, false)
.addComponent(text_id)
.addComponent(text_filepath, GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE)
.addComponent(text_basePath)
.addComponent(text_keywords)
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(button_6)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addComponent(button_8, GroupLayout.PREFERRED_SIZE, 124, GroupLayout.PREFERRED_SIZE)
.addComponent(button_7, GroupLayout.PREFERRED_SIZE, 124, GroupLayout.PREFERRED_SIZE))))
.addGap(18)
.addComponent(label_3)
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(button)
.addGap(18)
.addComponent(button_4)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(btnNewButton))
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(button_2)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(button_1)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(button_5))
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(btnid)
.addGap(18)
.addComponent(button_3))
.addComponent(label_2, GroupLayout.DEFAULT_SIZE, 688, Short.MAX_VALUE)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(42)
.addComponent(updateFilePath, GroupLayout.PREFERRED_SIZE, 225, GroupLayout.PREFERRED_SIZE))))
.addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 1053, GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 236, GroupLayout.PREFERRED_SIZE)
.addGap(20)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblNewLabel)
.addComponent(text_id, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(btnid)
.addComponent(button_3))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(text_filepath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(label)
.addComponent(button)
.addComponent(button_4)
.addComponent(btnNewButton))
.addGap(11)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(text_keywords, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(label_1)
.addComponent(button_2)
.addComponent(button_1)
.addComponent(button_5))
.addGap(18)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(text_basePath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(lblNewLabel_1)
.addComponent(label_2))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(button_6)
.addComponent(button_7)
.addComponent(updateFilePath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(label_3))
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(button_8)
.addGap(589)
.addComponent(textField_2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
contentPane.setLayout(gl_contentPane);
}
//list对象集合转为二维数组,这个方法不太通用,第二个长度 4 可以设置为变量
public static String[][] listToArr(List<MyFiles> listSongs){
if(listSongs!=null&&listSongs.size()>0){
String[][] aa=new String[listSongs.size()][4];
int index=0;
for (MyFiles songs : listSongs) {
aa[index][0]="序号:"+(index+1)+"==文件id号:"+songs.getId();
aa[index][1]=songs.getFileName();
aa[index][2]=songs.getFileuuid();
aa[index][3]=songs.getKeywords();
index++;
}
return aa;
}else{
return null;
}
}
}