ImageVerifierCode 换一换
格式:DOCX , 页数:28 ,大小:132.16KB ,
资源ID:8612353      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/8612353.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(吉林大学珠海学院java课程设计报告.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

吉林大学珠海学院java课程设计报告.docx

1、吉林大学珠海学院java课程设计报告课 程 设 计 报 告学院、系:吉林大学珠海学院计算机科学与技术系专业名称:计算机科学与技术课程设计科目java程序课程设计学生姓名:指导教师:朱云完成时间:2013.04.20题目:功能较完善的文件管理器一、设计任务与目标我们选择的题目是:实现一个能够对文件和文件夹进行各种基本操作的文件管理器窗口程序。功能要求:1)新建、删除、修改、复制、黏贴文件功能2)新建、删除、修改目录3)具有对某个文件进行压缩打包的功能4)要求实现多文档界面5)要求界面美观、功能布局合理。由于是两个人合作完成所以一开始我们就分工合作,我完成第二和第三个功能,何向强同学完成第一和第四

2、个功能。由于软件难度还是很大,所以我们研究了很久,大概理清思路!我曾经阅读过,关于java压缩的书所以通过一点点尝试将写出来,而何向强同学对界面方面比较熟悉,所以他就主要负责界面方面的!二、方案设计与论证根据题目的要求,我们想通过JTree来实现遍历文件夹并建成目录树,JList来实现多行显示,界面方面我们准备做成双栏式的,左边目录数,右边文件列表。由于我们之前没实践过这方面的项目,因此遇到很多困难。后来,通过阅读javax.swing.JFileChooser类的功能原码来逐步完善,新建、删除、复制等功能我们会通过java.io.File来了解文件的底层操作来完成。还有增加了一个时钟功能,通

3、过zip进行简单的压缩!3、程序框图或流程图,程序清单与调用关四、全部源程序清单/ scaner类/import javax.swing.*; import javax.swing.event.*; import javax.swing.tree.*; import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.*; public class scaner extends JFrame implements ActionListener,TreeExpansionListener,TreeSele

4、ctionListener JTree jtree = new JTree(createTreeModel(); JPanel JPsub=new JPanel(new GridLayout(0,1); JPanel road=new JPanel(new BorderLayout(); JFrame f,ff; JSplitPane JSP; /可滚动 JButton sure,ok; JLabel status=new JLabel( ); JLabel shijian,size; JTextField renamest,zipname; GregorianCalendar time =

5、new GregorianCalendar(); int hour = time.get(Calendar.HOUR_OF_DAY); int min = time.get(Calendar.MINUTE); int second = time.get(Calendar.SECOND); Vector v; JToolBar statusBar; JPopupMenu popupMenu; JMenuItem popupMenu_Copy, popupMenu_Delete,newfiles,p_zip; JMenuItem copy,del; JMenu m1, m2, m3; JMenuI

6、tem newItem, exitItem, zuozhe, help; JButton btt; JList F_list; PopupMenu menu; MenuItem b_open, b_copy, b_jiantie, b_del,newfile,b_rename,b_Zip,newfload; Object dizhi; FileDialog fd; long sizes; String newname;/构造函数 public scaner() super(文件管理器); /设置窗口大小 Container container = getContentPane();/时钟布局

7、int i = 400; int j = 100; setBounds(i,j,840,580); addWindowListener( new WindowAdapter() public void windowClosing(WindowEvent windowevent) System.exit(0); ; / m1 = new JMenu(文件) ; m2 = new JMenu(编辑) ; m3 = new JMenu(帮助) ; JMenuBar menuBar = new JMenuBar() ; menuBar.add(m1) ; menuBar.add(m2) ; menuB

8、ar.add(m3) ; newItem = new JMenuItem(新建文件) ; exitItem = new JMenuItem(退出) ; / 此时定义完了四个菜单的选项,定义完成之后,增加快捷键 newItem.setMnemonic(N) ; exitItem.setMnemonic(E) ; newItem.setAccelerator(KeyStroke.getKeyStroke(N,java.awt.Event.CTRL_MASK) ; exitItem.setAccelerator(KeyStroke.getKeyStroke(E,java.awt.Event.ALT_

9、MASK) ; newItem.addActionListener(this); /注册监听器 exitItem.addActionListener(this); m1.add(newItem) ; m1.add(exitItem) ; / copy = new JMenuItem(复制) ; del = new JMenuItem(删除) ; / 此时定义完了两个菜单的选项,定义完成之后,增加快捷键 copy.setMnemonic(C) ; copy.setAccelerator(KeyStroke.getKeyStroke(C,java.awt.Event.ALT_MASK) ; m2.

10、add(copy) ; m2.add(del) ; copy.addActionListener(this); del.addActionListener(this); / zuozhe = new JMenuItem(关于) ; help = new JMenuItem(帮助); m3.add(help); m3.add(zuozhe); zuozhe.addActionListener(this); help.addActionListener(this); / setJMenuBar(menuBar) ; / 菜单是需要通过此方法增加的 setVisible(true) ; /frame

11、.setSize(700,500) ; setLocation(300,200);/ / -创建右键弹出菜单 popupMenu = new JPopupMenu(); newfiles=new JMenuItem(新建文件夹); popupMenu_Copy = new JMenuItem(复制(C), C); popupMenu_Delete = new JMenuItem(删除(D), D); p_zip =new JMenuItem(添加到压缩文件); / -向右键菜单添加菜单项和分隔符 popupMenu.addSeparator(); popupMenu.add(newfiles)

12、; popupMenu.add(popupMenu_Copy); popupMenu.add(p_zip); popupMenu.add(popupMenu_Delete); popupMenu.addSeparator(); / -右键菜单注册事件 popupMenu_Copy.setActionCommand(复制(C); popupMenu_Copy.addActionListener(this); popupMenu_Delete.setActionCommand(删除(D); popupMenu_Delete.addActionListener(this); newfiles.set

13、ActionCommand(新建文件夹); newfiles.addActionListener(this); p_zip.addActionListener(this); jtree.add(popupMenu); / menu = new PopupMenu(); newfload=new MenuItem(新建文件夹); newfile=new MenuItem(新建文件); b_open=new MenuItem(打开); b_copy=new MenuItem(复制); b_Zip=new MenuItem(添加到压缩文件); b_del=new MenuItem(删除); b_re

14、name=new MenuItem(重命名); menu.addSeparator(); menu.add(b_open); menu.add(newfload); menu.add(newfile); menu.add(b_copy); menu.add(b_Zip); menu.add(b_rename); menu.add(b_del); menu.addSeparator(); b_open.addActionListener(this); newfload.addActionListener(this); b_copy.addActionListener(this); b_del.a

15、ddActionListener(this); b_Zip.addActionListener(this); b_rename.addActionListener(this); newfile.addActionListener(this); JPsub.add(menu);/ /水平分割窗口,左scrollPane内放tree,右放JPsub用于显示文件 JSP=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(jtree),new JScrollPane(JPsub); JSP.setDividerLocation (2

16、00);/设置分隔条的位置。 JSP.setLastDividerLocation(200); / 将分隔条所处的最后位置设置为 newLastLocation。 getContentPane().add(JSP);/背景色为白 JPsub.setBackground(Color.white); statusBar = new JToolBar(); shijian = new JLabel( 当前时间: + hour + : + min + : + second); statusBar.addSeparator(); statusBar.add(shijian); statusBar.set

17、Visible(true); container.add(statusBar, BorderLayout.SOUTH); statusBar.setVisible(true); / /给树添加展开监听器 jtree.addTreeExpansionListener(this); jtree.addTreeSelectionListener(this); /设置树的外形 ,改变文件夹的图案 try UIManager.setLookAndFeel(com.sun.java.swing.plaf.windows.WindowsLookAndFeel); SwingUtilities.updateC

18、omponentTreeUI(this); catch (Exception ex) jtree.setShowsRootHandles(true); getContentPane().add(road,BorderLayout.NORTH); road.add(status,BorderLayout.WEST); /西边.左边 Clock clock=new Clock();/线程 clock.start(); / f = new JFrame(重命名) ; f.setSize(230,80) ; / 设置组件的大小 f.setBackground(Color.WHITE) ; / 将背景设

19、置成白色 f.setLocation(300,200) ; / 设置组件的显示位置 renamest=new JTextField(); sure=new JButton(确定); f.add(renamest,BorderLayout.CENTER); f.add(sure,BorderLayout.SOUTH); sure.addActionListener(this); / ff = new JFrame(压缩文件名) ; ff.setSize(230,80) ; / 设置组件的大小 ff.setBackground(Color.WHITE) ; / 将背景设置成白色 ff.setLoc

20、ation(300,200) ; / 设置组件的显示位置 zipname=new JTextField(); ok=new JButton(确定); ff.add(zipname,BorderLayout.CENTER); ff.add(ok,BorderLayout.SOUTH); ok.addActionListener(this);/实现复制,黏贴功能/class MainFrame extends JFrame private static final long serialVersionUID = 1L;public MainFrame()super(COPY);setDefault

21、CloseOperation(HIDE_ON_CLOSE);setSize(500,260);setLocation(300,200) ;MainPanel pan = new MainPanel();setContentPane(pan);setLayout(null);class MainPanel extends JPanelprivate static final long serialVersionUID = 1L; JTextField txt; JTextArea txtInFile; JTextArea txtOutFile; JFileChooser open; String

22、 strFilePath; String strFilePathCopyTo; public MainPanel() JLabel lblIn = new JLabel(源文件:); lblIn.setBounds(30, 65, 50, 20); if(F_list.isSelectionEmpty() txtInFile = new JTextArea(zhantie(); else txtInFile = new JTextArea(zhantie()+F_list.getSelectedValue(); JScrollPane scrint = new JScrollPane(txtI

23、nFile) ; scrint.setBounds(80,65,265,40); JButton btnSelect = new JButton(选择文件或目录); btnSelect.setBounds(350, 65, 120, 20); open = new JFileChooser();/ txtInFile = new JTextArea(zhantie()+F_list.getSelectedValue(); open.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); open.setCurrentDirectory

24、(new File(zhantie(); btnSelect.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) open.showOpenDialog(null); strFilePath = open.getSelectedFile().getPath();/源文件路径 (JButton)e.getSource().setLabel(已选); txtInFile.setText(strFilePath); System.out.println(txtInFile.getText(

25、); System.out.println(打开文件); JLabel lblOut = new JLabel(复制到:); lblOut.setBounds(30, 125, 50, 20); txtOutFile = new JTextArea(); txtOutFile.setBounds(80,60,100,20); JScrollPane scrout = new JScrollPane(txtOutFile) ; scrout.setBounds(80,125,265,40); JButton btnSelectCopyTo = new JButton(选择目标路径); btnSe

26、lectCopyTo.setBounds(350, 125, 120, 20); btnSelectCopyTo.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) if(F_list.isSelectionEmpty() open.setSelectedFile(new File(zhantie(); else open.setSelectedFile(new File(zhantie()+F_list.getSelectedValue(); open.showSaveDialog

27、(null); strFilePathCopyTo = open.getSelectedFile().getPath(); (JButton)e.getSource().setLabel(已选); txtOutFile.setText(strFilePathCopyTo); System.out.println(txtOutFile.getText(); System.out.println(打开文件); ; JButton btnCopy = new JButton(开始复制); btnCopy.setBounds(130, 180, 90, 20); btnCopy.addActionLi

28、stener(new ActionListener() public void actionPerformed(ActionEvent e) strFilePath = txtInFile.getText(); strFilePathCopyTo = txtOutFile.getText(); System.out.println(strFilePath); System.out.println(strFilePathCopyTo); IOTest.copyFile(strFilePath, strFilePathCopyTo); add(lblIn); add(scrint); add(btnSelect); add(lblOut); add(scrout); add(btnSelectCopyTo); add(btnCopy);/树展开 public void treeExpanded

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1