JAVA-电子相册课程设计(共19页)_第1页
JAVA-电子相册课程设计(共19页)_第2页
JAVA-电子相册课程设计(共19页)_第3页
JAVA-电子相册课程设计(共19页)_第4页
JAVA-电子相册课程设计(共19页)_第5页
已阅读5页,还剩14页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、精选优质文档-倾情为你奉上中南大学JAVA课程设计 专业班级: 姓 名: 学 号: 指导老师: 目录 一设计背景电子相册是现在时下很流行的一种网络元素,它可以应用于很多的领域。其以静态照片为素材,配合动感的背景、字幕等视频处理的特殊效果,配上音乐就可制作成电子相册。制作好的电子相册可以在电脑上,各类影碟机上,以及手机和MP4里都能观看。当然,如果考虑到长期保存的话,也可以保存在硬盘上,也便于随时调阅、欣赏,永久保存。二需求分析1.采用的形式为:java application2.需要实现的主要功能是:(1)不同用户的登录模块(2)播放方式设置,需要要实现手动播放和自动播放照片等功能。(3)附加

2、背景音乐。(4)设置照片标题。三概要设计3.1功能说明该程序可以实现用户登录、新建相册、新增照片、删除照片、打开照片、播放照片等功能。3.2 布局说明由于本程序采用的是Java swing编程,所以采用的是布局为:javax.swing.GroupLayout,即群组布局。3.3 主要的工具包该程序中用到如下几个工具包,为:java.applet,java.awt,java.io,java.util以及javax.imageio和javax.swing。3.4程序主要流程图注:该流程图中部分是根据用户可能出现的操作进行的。打开程序N登录登陆成功Y相册界面删除相册打开相册重命名相册新建相册删除输

3、入相册名字进入相册界面输入相册名字删除照片移动照片打开照片设置标题自动播放添加照片下一张间隔时间暂停播放上一张四系统功能模块结构该电子相册程序分为登录相关模块、背景音乐播放模块、相册相关模块、照片相关模块、自动播放模块这五个模块。4.1 登录相关模块(1)业务描述:用户注册、登录功能。(2)业务说明:当用admin用户登录时,进入管理员界面,可以进行账户的添加、删除。应用普通账户登录,进入使用界面。 4.2 背景音乐模块(1)业务描述:自动播放音乐。(2)业务说明:当用户打开某一相册,点选自动播放时,背景音乐播出,退出背景音乐消失。(3)程序代码:public class autodispla

4、yListener2 extends JFrame implements ActionListener int i=-1; JDialog dialog=new JDialog(); int inttime=1;/ public autodisplayListener() / new Timer(1000,this).start(); / while(true); / Overridepublic void actionPerformed(ActionEvent e) autodisplayListener listener = new autodisplayListener(); Timer

5、 t = new Timer(1000,listener); musicplay= new MusicPlay("D:1.01.wav"); playview = new PlayView(model, Controller.this, userView.getSelectedAlbum().getText(); playview.getTimes().addActionListener(new ActionListener()Overridepublic void actionPerformed(ActionEvent e) inttime = Integer.parse

6、Int(playview.getTimes().getSelectedItem().toString();System.out.println("inttime"+inttime); ); 4.3 相册相关模块(1) 业务描述:相册及相关界面。(2) 业务流程:拥有新建、打开、重命名、删除相册的功能4.4 自动播放模块(1)业务描述:自动播放所导入的图片。(2)业务流程:i=-1YesNoi=i+1开始i=0editPhoto获得第i个图像的信息在主窗口显示editPhotoi=photoList-1重绘窗口延迟1秒是否结束线程Yes结束Noi<photoListYe

7、sNo 4.5 相片相关模式(1)业务描述:照片管理界面。(2)业务流程:拥有添加照片、打开照片、移动照片、删除照片、设置标题、自动播放等功能五系统实现5.1登录界面设计public LoginView(String title) super(title);setPreferredSize(new Dimension(WIN_WIDTH, WIN_HEIGHT);setMinimumSize(new Dimension(WIN_WIDTH, WIN_HEIGHT);GridBagLayout gridbag = new GridBagLayout();GridBagConstraints co

8、nstraints = new GridBagConstraints();setLayout(gridbag);constraints.weightx = 1.0;constraints.weighty = 1.0;constraints.gridx = 0;constraints.gridy = 0;constraints.insets = new Insets(20,0,40,0);constraints.gridwidth = GridBagConstraints.REMAINDER;JLabel loginText = new JLabel("电子相册登录:");g

9、ridbag.setConstraints(loginText, constraints);add(loginText);constraints.gridx = 0;constraints.gridy = 1;constraints.insets = new Insets(0,5,5,0);constraints.gridwidth = 1;JLabel usernameText = new JLabel("用户名:");gridbag.setConstraints(usernameText, constraints);add(usernameText);constrain

10、ts.gridx = 1;constraints.gridy = 1;constraints.anchor = GridBagConstraints.WEST;usernameField = new JTextField("", 10);gridbag.setConstraints(usernameField, constraints);add(usernameField);constraints.gridx = 0;constraints.gridy = 2;constraints.anchor = GridBagConstraints.CENTER;loginButto

11、n = new JButton("登录");gridbag.setConstraints(loginButton, constraints);add(loginButton);constraints.gridx = 0;constraints.gridy = 3;constraints.fill = GridBagConstraints.HORIZONTAL;constraints.gridwidth = GridBagConstraints.REMAINDER;errorMessage = new JLabel("");gridbag.setConst

12、raints(errorMessage, constraints);add(errorMessage);5.2 相册界面设计public UserView(Model model, Controller controller) super("用户: " + model.getUser().getUserID();this.controller = controller;this.model = model;setPreferredSize(new Dimension(WIN_WIDTH, WIN_HEIGHT);setMinimumSize(new Dimension(WI

13、N_WIDTH, WIN_HEIGHT);setResizable(false);getContentPane().setLayout(new BorderLayout();/Left panelbuttonPanel = new JPanel();buttonPanel.setPreferredSize(new Dimension(WIN_WIDTH/4, WIN_HEIGHT);buttonPanel.setMinimumSize(new Dimension(WIN_WIDTH/4, WIN_HEIGHT);buttonPanel.setLayout(new GridLayout(0,1,

14、0,20);/使用网格布局getContentPane().add(buttonPanel, BorderLayout.WEST);addAlbum = new JButton("新建相册");buttonPanel.add(addAlbum);openAlbum = new JButton("打开相册");openAlbum.setEnabled(false);buttonPanel.add(openAlbum);renameAlbum = new JButton("重命名相册");renameAlbum.setEnabled(fa

15、lse);buttonPanel.add(renameAlbum);deleteAlbum = new JButton("删除相册");deleteAlbum.setEnabled(false);buttonPanel.add(deleteAlbum);logout = new JButton("登出");buttonPanel.add(logout);/Right panelinfoPanel = new JPanel();infoPanel.setBackground(Color.white);getContentPane().add(infoPan

16、el, BorderLayout.CENTER);detailArea = new JTextArea("");detailArea.setEditable(false);detailArea.setColumns(52);detailArea.setRows(6);detailArea.setBackground(Color.LIGHT_GRAY);infoPanel.add(detailArea);albumPanel = new JScrollPane();albumPanel.setMinimumSize(new Dimension(3*WIN_WIDTH/4-20

17、, 3*WIN_HEIGHT/4);albumPanel.setPreferredSize(new Dimension(3*WIN_WIDTH/4-20, 3*WIN_HEIGHT/4);albumListPanel = new JPanel();albumListPanel.setLayout(new GridLayout(3,0,0,0);albumListPanel.setBackground(Color.white);albumListPanel.setMinimumSize(new Dimension(3*WIN_WIDTH/4-20, 2*WIN_HEIGHT/4);albumLi

18、stPanel.setMaximumSize(new Dimension(3*WIN_WIDTH/4-20, 100*WIN_HEIGHT);albumPanel.setViewportView(albumListPanel);infoPanel.add(albumPanel);5.3 新建相册 5.4照片界面设计public albumview(Model model, Controller controller, String albumName) super("用户: " + model.getUser().getUserID() + " 相册名称 &quo

19、t;" + albumName +""");this.controller = controller;this.model = model;this.albumName = albumName;photoList = model.getUser().getAlbum(albumName).getPhotos();setPreferredSize(new Dimension(WIN_WIDTH, WIN_HEIGHT);setMinimumSize(new Dimension(WIN_WIDTH, WIN_HEIGHT);setResizable(fals

20、e);getContentPane().setLayout(new BorderLayout();/Left panelbuttonPanel = new JPanel();buttonPanel.setPreferredSize(new Dimension(WIN_WIDTH/4, WIN_HEIGHT);buttonPanel.setMinimumSize(new Dimension(WIN_WIDTH/4, WIN_HEIGHT);buttonPanel.setLayout(new GridLayout(8,1,0,12);getContentPane().add(buttonPanel

21、, BorderLayout.WEST);addPhoto = new JButton("添加照片");buttonPanel.add(addPhoto);openPhoto=new JButton("打开照片");openPhoto.setEnabled(false);buttonPanel.add(openPhoto);movePhoto = new JButton("移动照片");movePhoto.setEnabled(false);buttonPanel.add(movePhoto);deletePhoto = new JB

22、utton("删除照片");deletePhoto.setEnabled(false);buttonPanel.add(deletePhoto);recaption = new JButton("设置标题");recaption.setEnabled(false);buttonPanel.add(recaption);autodisplay = new JButton("自动播放");buttonPanel.add(autodisplay);back = new JButton("返回");buttonPanel.

23、add(back);/Right panelinfoPanel = new JPanel();infoPanel.setBackground(Color.white);getContentPane().add(infoPanel, BorderLayout.CENTER);detailArea = new JTextArea("");detailArea.setEditable(false);detailArea.setColumns(52);detailArea.setRows(6);detailArea.setBackground(Color.LIGHT_GRAY);i

24、nfoPanel.add(detailArea);photoPanel = new JScrollPane();photoPanel.setMinimumSize(new Dimension(3*WIN_WIDTH/4-20, 3*WIN_HEIGHT/4);photoPanel.setPreferredSize(new Dimension(3*WIN_WIDTH/4-20, 3*WIN_HEIGHT/4);photoListPanel = new JPanel();photoListPanel.setBackground(Color.white);photoListPanel.setMini

25、mumSize(new Dimension(3*WIN_WIDTH/4-20, 2*WIN_HEIGHT/4);photoListPanel.setMaximumSize(new Dimension(3*WIN_WIDTH/4-20, 100*WIN_HEIGHT);photoPanel.setViewportView(photoListPanel);photoListPanel.setLayout(new GridLayout(1, 0, 0, 0);infoPanel.add(photoPanel);5.5播放功能设计“上一张”,“下一张”,“自动”,“延时时间”等设计如上面流程图所示。p

26、ublic PlayView(Model model,Controller controller,String albumName)super("用户: " + model.getUser().getUserID() + " 相册名称 "" + albumName +""");this.controller = controller;this.albumName = albumName;setPreferredSize(new Dimension(WIN_WIDTH, WIN_HEIGHT);setMinimumS

27、ize(new Dimension(WIN_WIDTH, WIN_HEIGHT);setResizable(false);getContentPane().setLayout(new BorderLayout();/Left panelbuttonPanel = new JPanel();buttonPanel.setPreferredSize(new Dimension(WIN_WIDTH, WIN_HEIGHT);buttonPanel.setMinimumSize(new Dimension(WIN_WIDTH, WIN_HEIGHT);buttonPanel.setLayout(new

28、 GridLayout(1,8,0,12);getContentPane().add(buttonPanel, BorderLayout.WEST);previous = new JButton("上一张");buttonPanel.add(previous);play=new JButton("播放");buttonPanel.add(play);pause = new JButton("暂停");pause.setEnabled(false);buttonPanel.add(pause);next = new JButton("下一张");buttonPanel.add(next);timestext = new JLabel("间隔时间(秒):");buttonP

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论