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个
5星 · 超过95%的资源 需积分: 50 270 下载量 78 浏览量
2018-05-21
15:27:31
上传
评论 38
收藏 1.81MB ZIP 举报
温馨提示
1. 模仿Windows的文件资源管理器对本机的文件目录树的显示,对文件目录进行查看和浏览,用地址栏、文件目录树、打开文件夹等方法都可以在文件目录之间进行跳转 2. 对文件的基本操作:打开、删除、批量删除、重命名、相关属性查看 3. 对磁盘的基本操作:打开、容量及相关属性查看 4. 按需筛选选定目录下的视频、音乐、图片、文本文档类文件 5. 按关键字对文件/文件夹进行检索
资源推荐
资源详情
资源评论
收起资源包目录
FileManager.zip (37个子文件)
FileManager
.project 387B
src
BLL
DirectoryInfo.java 1KB
MemoryInfo.java 729B
FileDelete.java 3KB
DriveChart.java 2KB
GetFileNames.java 827B
FileSearch.java 3KB
GetFileIcon.java 1KB
FileTime.java 2KB
FilesTree.java 9KB
UI
FileProperties.java 14KB
MainForm.java 20KB
MyCellRenderer.java 1KB
lib
gnujaxp-1.0.0.jar 227KB
jcommon-1.0.16.jar 302KB
jfreechart-1.0.13.jar 1.36MB
.settings
org.eclipse.jdt.core.prefs 598B
org.eclipse.core.resources.prefs 75B
.classpath 638B
bin
BLL
MemoryInfo.class 1KB
FileTime.class 2KB
GetFileNames.class 1KB
DriveChart.class 3KB
FilesTree$1.class 1KB
FileDelete.class 2KB
GetFileIcon.class 2KB
FilesTree.class 2KB
FilesTree$2.class 885B
FilesTree$FileTreeCellRenderer.class 3KB
DirectoryInfo.class 1KB
FilesTree$FileTreeNode.class 2KB
FileSearch.class 3KB
FilesTree$FileTreeNode$1.class 1KB
UI
FileProperties.class 10KB
MyCellRenderer.class 2KB
MainForm$1.class 2KB
MainForm.class 18KB
共 37 条
- 1
资源评论
- WuchangI2018-10-18不错的资源,顺便推一下我用C#实现的一个资源管理器,可以直接查看运行效果,欢迎star、fork~~ https://github.com/Yuziquan/MyFileManager
- rijin03272020-03-04非常棒,连Mac上运行也正常,学习下
IamGroot!
- 粉丝: 105
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功