package UI;
import BLL.*;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributes;
import java.text.DecimalFormat;
import java.util.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.filechooser.FileSystemView;
import javax.swing.tree.DefaultMutableTreeNode;
public class MainForm extends JFrame implements ActionListener{
public static MainForm _instance;
JPanel p, SortPanel, SearchPanel, ShowPanel, FunctPanel, TreePanel;
JTree BigTree;
FilesTree filesTree;
JScrollPane ScrollShow, TreeShow;
JRadioButton AllFiles,Videos,Text,Picture,Music;
DefaultMutableTreeNode node;
JButton PreBtn, LatBtn, GoBtn;
ButtonGroup Classify;
JComboBox SortList, SortType;
JTextField SearchText, GuideText;
JCheckBox FileCheck, DirCheck;
JLabel SortTxt, SearchTxt, SearchType;
String Sort_Items[] = {"文件大小","修改时间","首字母"};
String Sort_Type_Items[] = {"升序","降序"};
public String Cur_URL = "";
String Pre_URL = "";
String LatURL = "";
//各类文件格式匹配的初始化
List<String> VideoType = Arrays.asList("avi","wmv","rm","rmvb","mpeg1","mpeg2","mpeg4","mp4","3gp","asf","swf","vob","dat","mov","m4v","flv","f4v","mkv","mts","ts","qsv","AVI","WMV","RM","RMVB","MPEG1","MPEG2","MPEG4","MP4","3GP","ASF","SWF","VOB","DAT","MOV","M4V","FLV","F4V","MKV","MTS","TS","QSV");
List<String> GraphType = Arrays.asList("bmp","gif","jpeg","jpeg2000","tiff","psd","png","swf","svg","pcx","dxf","wmf","emf","lic","eps","tga","jpg","BMP","GIF","JPEG","JPEG2000","TIFF","PSD","PNG","SWF","SVG","PCX","DXF","WMF","EMF","LIC","EPS","TGA","JPG");
List<String> TxtType = Arrays.asList("txt","doc","docx","wps","pdf","chm","pdg","wdl","xls","xlsx","ppt","pptx","java","c","cpp","py");
List<String> MusicType = Arrays.asList("cd","wave","wav","aiff","au","mp3","midi","wma","aac","ape","CD","WAVE","WAV","AIFF","AU","MP3","MIDI","WMA","RealAudio","VQF","OggVorbis","AAC","APE");
public Map<String, String> Maps = new HashMap<String,String>();
//文件列表的相关变量
JList<String> list;
public DefaultListModel defaultListModel;
public Stack<String> stack, stack_return;
JPopupMenu jPopupMenu = null;
JPopupMenu jPopupMenu2 = null;
JPopupMenu jPopupMenu3 = null;
JMenuItem[] JMIs = new JMenuItem[10];
JMenuItem[] JMIs2 = new JMenuItem[5];
JMenuItem delete = new JMenuItem("删除");
public Icon[] AllIcons = new Icon[999999];//存储搜索得到的文件图标
public int Icon_Counter = 0;
//保存GB,MB,KB,B对应的字节数,方便换算文件大小及单位
long[] Sizes = {1073741824,1048576,1024,1};
String[] Size_Names = {"GB", "MB", "KB", "B"};
Boolean isSearching = false;
public MainForm(){//主界面
this._instance = this;
this.setTitle("文件管家");
this.setBounds(500, 500, 1010, 650);
this.getContentPane().setLayout(null);
Init();
this.setLocationRelativeTo(null);
this.setVisible(true);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setResizable(false);
}
public void Init(){
//各个panel初始化
p = new JPanel();
SortPanel = new JPanel();
SearchPanel = new JPanel();
ShowPanel = new JPanel();
FunctPanel = new JPanel();
TreePanel = new JPanel();
p.setBounds(5, 5, 1000, 50);
p.setLayout(new FlowLayout(FlowLayout.LEFT,15,5));
//顶部查询搜索模块
SortPanel.setSize(200, 80);
SortPanel.setLayout(new FlowLayout());
//类别JRadioButton初始化
AllFiles = new JRadioButton("所有文件");
AllFiles.setSelected(true);
Videos = new JRadioButton("视频");
Picture = new JRadioButton("图片");
Music = new JRadioButton("音乐");
Text = new JRadioButton("文档");
Videos.addActionListener(this);
Picture.addActionListener(this);
Music.addActionListener(this);
Text.addActionListener(this);
AllFiles.addActionListener(this);
Classify = new ButtonGroup();
Classify.add(AllFiles);
Classify.add(Videos);
Classify.add(Picture);
Classify.add(Music);
Classify.add(Text);
SortTxt = new JLabel("排序");
SortList = new JComboBox(Sort_Items);
SortType = new JComboBox(Sort_Type_Items);
SortPanel.add(SortTxt);
SortPanel.add(SortList);
SortPanel.add(SortType);
SearchTxt = new JLabel("搜索");
SearchTxt.setBounds(5,5,50,30);
SearchText = new JTextField(15);
SearchText.setBounds(50, 5, 120, 30);
SearchText.addActionListener(this);
SearchType = new JLabel("搜索类型");
FileCheck = new JCheckBox("文件");
FileCheck.setSelected(true);
DirCheck = new JCheckBox("目录");
DirCheck.setSelected(true);
FileCheck.addActionListener(this);
DirCheck.addActionListener(this);
p.add(AllFiles);
p.add(Videos);
p.add(Picture);
p.add(Music);
p.add(Text);
p.add(SortPanel);
p.add(SearchTxt);
p.add(SearchText);
p.add(SearchType);
p.add(FileCheck);
p.add(DirCheck);
//中上导航栏35
FunctPanel = new JPanel();
FunctPanel.setBounds(5, 50, 990, 45);
FunctPanel.setLayout(null);
PreBtn = new JButton("<");
PreBtn.setFont(new Font("Serif", Font.PLAIN, 20));
PreBtn.setBounds(5, 5, 85, 25);
PreBtn.addActionListener(this);
LatBtn = new JButton(">");
LatBtn.setFont(new Font("Serif", Font.PLAIN, 20));
LatBtn.setBounds(85, 5, 85, 25);
LatBtn.addActionListener(this);
GuideText = new JTextField();
GuideText.setBounds(180, 5, 740, 25);
GuideText.addActionListener(this);
GoBtn = new JButton("Go!");
GoBtn.setFont(new Font("Serif", Font.PLAIN, 15));
GoBtn.setBounds(925, 5, 65, 25);
GoBtn.addActionListener(this);
FunctPanel.add(PreBtn);
FunctPanel.add(LatBtn);
FunctPanel.add(GuideText);
FunctPanel.add(GoBtn);
this.add(FunctPanel);
//中部文件列表
stack = new Stack<String>();
stack_return = new Stack<String>();
ShowPanel.setSize(800, 610);
ShowPanel.setLocation(200, 90);
ShowPanel.setLayout(null);
list = new JList<String>();
jPopupMenu = new JPopupMenu();//文件/文件夹的属性菜单
jPopupMenu2 = new JPopupMenu();//磁盘的属性菜单
JMIs[0] = new JMenuItem("打开");
JMIs[1] = new JMenuItem("删除");
JMIs[2] = new JMenuItem("重命名");
JMIs[3] = new JMenuItem("属性");
for(int k = 0; k < 4; ++k){//文件/文件夹的属性菜单初始化
JMIs[k].addActionListener(this);
jPopupMenu.add(JMIs[k]);
}
JMIs2[0] = new JMenuItem("打开");
JMIs2[1] = new JMenuItem("属性");
for(int k = 0; k < 2; ++k){//磁盘的属性菜单初始化
JMIs2[k].addActionListener(this);
jPopupMenu2.add(JMIs2[k]);
}
jPopupMenu3 = new JPopupMenu();
delete.addActionListener(this);
jPopupMenu3.add(delete);
list.add(jPopupMenu3);
list.add(jPopupMenu2);
list.add(jPopupMenu);
Home_List();//显示磁盘根目录
list.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e){
if(list.getSelectedIndex() != -1){
if(e.getClickCount() == 1){//单击l
没有合适的资源?快使用搜索试试~ 我知道了~
java实现的本地文件管理器——仿Windows文件资源管理器

共37个文件
class:18个
java:12个
jar:3个


温馨提示
1. 模仿Windows的文件资源管理器对本机的文件目录树的显示,对文件目录进行查看和浏览,用地址栏、文件目录树、打开文件夹等方法都可以在文件目录之间进行跳转 2. 对文件的基本操作:打开、删除、批量删除、重命名、相关属性查看 3. 对磁盘的基本操作:打开、容量及相关属性查看 4. 按需筛选选定目录下的视频、音乐、图片、文本文档类文件 5. 按关键字对文件/文件夹进行检索
资源推荐
资源详情
资源评论


















收起资源包目录















































共 37 条
- 1
资源评论

- WuchangI2018-10-18不错的资源,顺便推一下我用C#实现的一个资源管理器,可以直接查看运行效果,欢迎star、fork~~ https://github.com/Yuziquan/MyFileManager
- rijin03272020-03-04非常棒,连Mac上运行也正常,学习下

IamGroot!
- 粉丝: 108
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 基于城域网架构的网络阅卷系统的分析与设计.docx
- PowerPoint演示文稿制作软件.ppt
- 辽宁互联网+农产品销售模式创新研究.docx
- 电力行业电气工程及其自动化专业应聘时必知东东.doc
- 物联网在精准农业中的应用探析.docx
- IoT物联网解决方案及应用案例.pptx
- 让教学研究在网络的推动下稳步前行.doc
- 视觉图像的二进制表示学习与哈希技术
- 第1章-通信电源系统组成.ppt
- 广东省广州市中学20112012学七级信息技术-计算机文库.ppt
- 网络数码扩印系统的设计与实现.docx
- 浅析水利工程项目管理及措施.docx
- 基于大数据分析实验室的应用数学和统计类本科生培养模式研究-.docx
- 半桥计算机毕业设计.doc
- 电子商务崛起背后的安全问题研究.doc
- 单片机音乐播放器方案设计书报告[1].doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
