JAVA毕业设计Word格式.docx

上传人:b****4 文档编号:16681593 上传时间:2022-11-25 格式:DOCX 页数:12 大小:17.69KB
下载 相关 举报
JAVA毕业设计Word格式.docx_第1页
第1页 / 共12页
JAVA毕业设计Word格式.docx_第2页
第2页 / 共12页
JAVA毕业设计Word格式.docx_第3页
第3页 / 共12页
JAVA毕业设计Word格式.docx_第4页
第4页 / 共12页
JAVA毕业设计Word格式.docx_第5页
第5页 / 共12页
点击查看更多>>
下载资源
资源描述

JAVA毕业设计Word格式.docx

《JAVA毕业设计Word格式.docx》由会员分享,可在线阅读,更多相关《JAVA毕业设计Word格式.docx(12页珍藏版)》请在冰豆网上搜索。

JAVA毕业设计Word格式.docx

该程序中用到如下几个工具包,为:

importjava.awt.Dimension;

importjava.awt.Toolkit;

importjava.awt.event.ActionEvent;

importjava.awt.event.ActionListener;

importjavax.swing.JButton;

importjavax.swing.JFrame;

importjavax.swing.JLabel;

importjavax.swing.JOptionPane;

importjavax.swing.JPasswordField;

importjavax.swing.JTextField;

importjava.awt.*;

importjavax.swing.*;

importjava.io.*;

importjava.awt.event.*;

importjava.applet.AudioClip;

importjava.applet.Applet;

importjava.awt.Frame;

import.MalformedURLException;

import.URI;

import.URL;

四.系统功能模块结构

该电子相册程序分为登录相关模块、背景音乐播放模块、相册相关模块这3个模块。

五.系统实现

import.www.content.audio.wav;

publicclassPictureExplorerextendsJFrameimplementsActionListener{

privateJLabelimagelabel;

privateJPanelpanel;

privateinti=0;

Stringfilename;

Filefile;

privateImageIconimage;

privateJButtonstartbutton,stopbutton,previousbutton,nextbutton;

privateJMenuBarmenubar;

privateJMenumenu;

privateJMenuItemmenuitemopen,menuitemexit;

privateJFileChooserchooser;

Filef;

URIuri;

URLurl;

publicPictureExplorer(){

try{

f=newFile("

/Users/kiminatosaku/Downloads/1.wav"

);

uri=f.toURI();

url=uri.toURL();

//解析地址

AudioClipaau;

aau=Applet.newAudioClip(url);

aau.loop();

//循环播放

}catch(Exceptione)

{

e.printStackTrace();

}

imagelabel=newJLabel();

panel=newJPanel();

image=newImageIcon();

startbutton=newJButton("

放大"

stopbutton=newJButton("

缩小"

previousbutton=newJButton("

上一张"

nextbutton=newJButton("

下一张"

menubar=newJMenuBar();

menu=newJMenu("

文件"

menuitemopen=newJMenuItem("

打开文件"

menuitemexit=newJMenuItem("

退出"

chooser=newJFileChooser();

}

publicvoidlaunchPictureExplorerTest(){

Containerc=getContentPane();

startbutton.addActionListener(this);

stopbutton.addActionListener(this);

previousbutton.addActionListener(this);

nextbutton.addActionListener(this);

menuitemopen.addActionListener(this);

menuitemexit.addActionListener(this);

menubar.add(menu);

menu.add(menuitemopen);

menu.add(menuitemexit);

imagelabel.setIcon(image);

imagelabel.setHorizontalAlignment(SwingConstants.CENTER);

c.add(imagelabel,"

Center"

panel.add(previousbutton);

panel.add(nextbutton);

panel.add(startbutton);

panel.add(stopbutton);

c.add(panel,"

South"

chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);

chooser.setCurrentDirectory(newFile("

."

));

//设置文件选择器当前目录

chooser.setFileFilter(newjavax.swing.filechooser.FileFilter(){

publicbooleanaccept(Filefile){//可接受的文件类型

Stringname=file.getName().toLowerCase();

//获取文件名

returnname.endsWith("

.gif"

||name.endsWith("

.jpg"

.jpeg"

||file.isDirectory();

}

publicStringgetDescription(){

return"

图像文件"

;

});

setJMenuBar(menubar);

setSize(800,600);

setLocation(100,100);

setTitle(filename);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setVisible(true);

publicvoidactionPerformed(ActionEvente){

Objectsource=e.getSource();

if(source==menuitemopen){

intresult=chooser.showOpenDialog(this);

//显示文件选择对话框

if(result==JFileChooser.APPROVE_OPTION){

Stringfilename=chooser.getSelectedFile().getAbsolutePath();

image=newImageIcon(filename);

ImageIconicon=newImageIcon();

icon=image;

doublewidthratio=image.getIconWidth()*1.0/imagelabel.getWidth();

doubleheightratio=image.getIconHeight()*1.0/imagelabel.getWidth();

if(widthratio<

=1&

&

heightratio<

=1){

imagelabel.setIcon(image);

intwidth=-1,height=-1;

if(heightratio>

=widthratio){

height=imagelabel.getHeight();

else

{

width=imagelabel.getWidth();

image=newImageIcon(icon.getImage().getScaledInstance(width,height,Image.SCALE_SMOOTH));

imagelabel.setIcon(image);

}

elseif(source==menuitemexit)

System.exit

(1);

elseif(source==previousbutton){

File[]files;

file=chooser.getSelectedFile().getParentFile();

files=file.listFiles();

if(i>

0&

i<

files.length)

i--;

//i<

files.length;

Stringfilename=files[i].getAbsolutePath();

if(heightratio>

else{

elseif(source==nextbutton){

=0&

i++;

elseif(source==startbutton){

height=imagelabel.getHeight()*2;

width=imagelabel.getWidth()*2;

elseif(source==stopbutton){

doublewidth=-1,height=-1;

height=imagelabel.getHeight()*0.5;

width=imagelabel.getWidth()*0.5;

image=newImageIcon(icon.getImage().getScaledInstance((int)width,(int)height,Image.SCALE_SMOOTH));

publicstaticvoidmain(String[]arges){

finalStringuserName="

abc"

finalStringpasswrod="

123"

JFramejFrame=newJFrame("

登陆界面"

Dimensiondimension=Toolkit.getDefaultToolkit().getScreenSize();

jFrame.setBounds(((int)dimension.getWidth()-200)/2,((int)dimension.getHeight()-300)/2,200,150);

jFrame.setResizable(false);

jFrame.setLayout(null);

jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JLabellabel1=newJLabel("

姓名"

label1.setBounds(10,10,100,30);

jFrame.add(label1);

JLabellabel2=newJLabel("

密码"

label2.setBounds(10,40,100,30);

jFrame.add(label2);

finalJTextFieldtext1=newJTextField();

text1.setBounds(50,15,130,20);

jFrame.add(text1);

finalJPasswordFieldtext2=newJPasswordField();

text2.setBounds(50,45,130,20);

jFrame.add(text2);

JButtonbutton=newJButton("

Login"

button.setBounds(10,75,170,40);

button.addActionListener(newActionListener(){

@Override

publicvoidactionPerformed(ActionEvente){

if(userName.equals(text1.getText())&

passwrod.equals(text2.getText())){

JOptionPane.showMessageDialog(null,"

登陆成功"

"

提示"

JOptionPane.INFORMATION_MESSAGE);

}else{

错误"

JOptionPane.ERROR_MESSAGE);

text1.setText("

"

text2.setText("

}

});

jFrame.add(button);

jFrame.setVisible(true);

PictureExplorerpe=newPictureExplorer();

pe.launchPictureExplorerTest();

newPictureExplorer();

}

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 求职职场 > 简历

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

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