package ui;
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.FlowLayout;
import javax.swing.JFileChooser;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.io.File;
import java.util.ArrayList;
import java.util.logging.FileHandler;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JMenu;
import org.com.*;
import com.sun.xml.internal.bind.v2.schemagen.xmlschema.List;
public class ui1 extends JFrame {
private JPanel contentPane;
private JFileChooser filechooser;
File file;
/**
* Launch the application.
*/
public static void man() {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
ui1 frame = new ui1();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public ui1() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
JMenuBar menuBar = new JMenuBar();
setJMenuBar(menuBar);
JMenu menu = new JMenu("\u6587\u4EF6");
menuBar.add(menu);
JMenuItem menuItem_3 = new JMenuItem("\u5220\u9664");
menu.add(menuItem_3);
JMenu mnNewMenu = new JMenu("编辑");
menuBar.add(mnNewMenu);
JMenuItem menuItem = new JMenuItem("\u6DFB\u52A0");
mnNewMenu.add(menuItem);
JMenuItem menuItem_1 = new JMenuItem("\u65B0\u5EFA\u6587\u4EF6\u5939");
mnNewMenu.add(menuItem_1);
JMenu mnNewMenu_1 = new JMenu("查看");
menuBar.add(mnNewMenu_1);
contentPane = new JPanel();
setContentPane(contentPane);
JButton btnNewButton = new JButton("word");
btnNewButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
String defaultDisk="E:\\分类\\doc";
filechooser.setCurrentDirectory(new File(defaultDisk));
}
});
//ListRoots list = new ListRoots();
// TODO Auto-generated method stub
//File f = list.f ;
//File[] files=f.listFiles();
//new File("E:"+File.separator+"abc"+File.separator+"abc");
// for(int )
// file.mkdir();
//file.mkdirs();
btnNewButton.setBounds(11, 10, 93, 23);
contentPane.add(btnNewButton);
JButton btnNewButton_1 = new JButton("ppt");
btnNewButton_1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
String defaultDisk="E:\\分类\\ppt";
filechooser.setCurrentDirectory(new File(defaultDisk));
}
});
btnNewButton_1.setBounds(11, 43, 93, 23);
contentPane.add(btnNewButton_1);
JButton btnNewButton_2 = new JButton("mv");
btnNewButton_2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO 自动生成的方法存根
String defaultDisk="E:\\分类\\mv";
filechooser.setCurrentDirectory(new File(defaultDisk));
}
});
btnNewButton_2.setBounds(11, 76, 93, 23);
contentPane.add(btnNewButton_2);
JButton btnNewButton_3 = new JButton("music");
btnNewButton_3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
String defaultDisk="E:\\分类\\mp3";
filechooser.setCurrentDirectory(new File(defaultDisk));
}
});
btnNewButton_3.setBounds(11, 109, 93, 23);
contentPane.add(btnNewButton_3);
JButton btnNewButton_4 = new JButton("jpg");
btnNewButton_4.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO 自动生成的方法存根
String defaultDisk="E:\\分类\\jpg";
filechooser.setCurrentDirectory(new File(defaultDisk));
}
});
btnNewButton_4.setBounds(11, 109, 93, 23);
contentPane.add(btnNewButton_4);
JButton btnNewButton_6 = new JButton("选择");
btnNewButton_6.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO 自动生成的方法存根
String path = filechooser.getSelectedFile().getAbsolutePath();
file = filechooser.getSelectedFile();
}
});
btnNewButton_6.setBounds(11, 109, 93, 23);
contentPane.add(btnNewButton_6);
JButton btnNewButton_5= new JButton("打开");
btnNewButton_5.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO 自动生成的方法存根
Desktop desktop=Desktop.getDesktop();
try {
desktop.open(file);
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
});
btnNewButton_5.setBounds(11, 109, 93, 23);
contentPane.add(btnNewButton_5);
JButton button = new JButton("\u8FDB\u884C\u5206\u7C7B");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ListRoots listRoots=new ListRoots();
ArrayList<String> list= listRoots.listpath;
for(int i=0;i<list.size();i++)
{//对文件经行截取 获取文件扩展名
String strFile=list.get(i).toString();
int index=strFile.lastIndexOf(".");
if(index!=-1){
String strN1=strFile.substring(index+1,strFile.length());
int ind=strFile.lastIndexOf("\\");
String strFileName = strFile.substring(ind,index);
//创建文件夹得方法 新建文件夹
listRoots.createFolder("E:"+"\\"+"分类");
listRoots.createFolder("E:"+"\\"+"分类"+"\\"+strN1);
if(strFile.endsWith(strN1))
{
listRoots.copyFile(strFile,"E:"+"\\"+"分类"+"\\"+strN1+"\\"+strFileName+strFile.substring(index,strFile.length()));
}
}
}
JOptionPane.showMessageDialog(getContentPane(),"文件分类成功","信息提示框",JOptionPane.WARNING_MESSAGE);
}
});
button.setBounds(11, 142, 93, 23);
contentPane.add(button);
//JOptionPane.showMessageDialog(getContentPane(),"文件分类成功","信息提示框",JOptionPane.WARNING_MESSAGE);
filechooser=new JFileChooser();
contentPane.add(filechooser,BorderLayout.CENTER);
//contentPane.setSize(3000,3000);
//getContentPane().add(contentPane);
//setSize(700,600);
// int result = filechooser.showOpenDialog(this);
//if (result == JFileChooser.APPROVE_OPTION) {
// String path = filechooser.getSelectedFile().getAbsolutePath();
//file = filechooser.getSelectedFile();
//}
}
/* public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
if(e.getSource()=="ppt")
{String defaultDisk="E:\\分类\\ppt";
filechooser.setCurrentDirectory(new File(defaultDisk));
System.out.print("ppt");
//contentPane.add(filechooser,BorderLayout.CENTER);
}
/*else if(e.getSource()=="word")
{
String defaultDisk="E:\\分类\\doc";
filechooser.setCurrentDirectory(new File(defaultDisk));
contentPane.add(filechooser,BorderLayout.CENTER);
System.out.print("word");
}
else if(e.getSource()=="music")
{
String defaultDisk="E:\\分类\\mp3";
filechooser.setCurrentDirectory(new File(defaultDisk));
contentPane.add(filechooser,BorderLayout.CENTER);
System.out.print("music");
}
else if(e.getSource()=="mv")
{
String defaultDisk="E:\\分类\\mv";
filechooser.setCurrentDirectory(new File(defaultDisk));
contentPane.add(filechooser,BorderLayo
smm5551
- 粉丝: 0
- 资源: 6
最新资源
- js-leetcode题解之141-linked-list-cycle.js
- js-leetcode题解之140-word-break-ii.js
- js-leetcode题解之139-word-break.js
- js-leetcode题解之138-copy-list-with-random-pointer.js
- js-leetcode题解之136-single-number.js
- js-leetcode题解之135-candy.js
- js-leetcode题解之134-gas-station.js
- 基于tensorflow的道路桥梁裂缝检测应用源码
- 多台设备循环控制仿真和代码protues仿真
- 多台设备循环控制原理图
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈