功能实现:
1.窗口建立
2.实现文件查找、遍历
3.文件重命名
4.文件预览
5.文件统计
6.鼠标双击获取路径
1.窗口建立
public class winsEvent {
JFrame frame;//窗体
JPanel jPanel;//面板
Container container;//容器
JTextField field1;//文本框提供输入路径
JButton bsearch,breturn,bcopy,bstick,bname,bpreview,brecord;//查找,返回,复制,粘贴,重命名,预览,统计
MyListener listener;
JList list;
JTextArea area;//文本区显示预览和统计
public winsEvent() {
frame = new JFrame("文件管理器");
frame.setBounds(200, 100, 800, 600); // 设置窗口大小和位置
frame.setLayout(new BorderLayout());
container = frame.getContentPane();//设置容器
jPanel = new JPanel(); // 创建面板
jPanel.setLayout(new FlowLayout(FlowLayout.LEADING));
first();
//窗体显示和关闭
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
void first() {
//定义
field1 = new JTextField(10);
field1.setText("");
bsearch = new JButton("查找");
bsearch.setActionCommand("bsearch");
breturn = new JButton("返回");
breturn.setActionCommand("breturn");
list = new JList();
bcopy = new JButton("复制");
bcopy.setActionCommand("bcopy");
bstick = new JButton("粘贴");
bstick.setActionCommand("bstick");
bname = new JButton("重命名");
bname.setActionCommand("bname");