网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

分类相册java代码 JAVA分类打印的代码要求依次输出

相册管理 java实现 功能是图片显示与图片放大缩小 急~~

上楼的我只想说你根本不懂java,这么简单的功能都不能实现,还是一门编程语言吗? 一、部分截图: ①打开 ②放大 ③翻转 ④缩小 二、源程序: import java.awt.*;

创新互联公司专业为企业提供江北网站建设、江北做网站、江北网站设计、江北网站制作等企业网站建设、网页设计与制作、江北企业网站模板建站服务,十余年江北做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

import java.awt.event.*;

import javax.swing.*;

import java.io.File;

public class PhotoFrame extends JFrame implements ActionListener{ Canvas photo;

JPanel p;

JButton open,bigger,smaller,rotate,exit;

JScrollPane sp;

JFileChooser fc;

int w = 150;

int h = 150;

Image image;

int rate = 10;//图片放缩率(单位:像素)

public PhotoFrame(){

init();

this.setTitle ("Java图片查看器");

this.setSize (600,500);

this.setLocationRelativeTo (this);//窗口居中

this.setVisible (true);

this.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);

}

public void init(){

photo = new Photo();

sp = new JScrollPane(photo);

p = new JPanel();

open = new JButton("open");

bigger = new JButton(" + ");

smaller = new JButton(" - ");

rotate = new JButton(" の ");

exit = new JButton("exit");

//设置前景色

open.setForeground (Color.BLUE);

bigger.setForeground (Color.GREEN);

smaller.setForeground (Color.GREEN);

rotate.setForeground (Color.GREEN);

exit.setForeground (Color.RED);

//设置提示文本

open.setToolTipText ("打开文件");

bigger.setToolTipText ("放大");

smaller.setToolTipText ("缩小");

rotate.setToolTipText ("翻转");

exit.setToolTipText ("退出程序");

//设置边框

p.setBorder (BorderFactory.createEtchedBorder ());

p.add (open);

p.add (bigger);

p.add (smaller);

p.add (rotate);

p.add (exit);

add(sp,BorderLayout.CENTER);

add(p,BorderLayout.SOUTH);

open.addActionListener (this);

bigger.addActionListener (this);

smaller.addActionListener (this);

rotate.addActionListener (this);

exit.addActionListener (this);

}

public static void main(String[] args){

new PhotoFrame();

} public void actionPerformed (ActionEvent e){

if(e.getSource ()==open){//打开

fc = new JFileChooser();

int returnval = fc.showOpenDialog(this);

if(returnval == JFileChooser.APPROVE_OPTION){

File f = fc.getSelectedFile ();

String fileName = f.getName ();

String filePath=fc.getSelectedFile().getAbsolutePath();

System.out.println(filePath);

this.setTitle (fileName+"-Java图片查看器");

//通过文件路径获得图片

image = new ImageIcon(filePath).getImage ();

//获取图片的宽和高

w = image.getWidth (this);

h = image.getHeight (this);

}

}else if(e.getSource ()==bigger){//放大

if(w0) w+= rate;

else w-= rate;

if(h0)h+= rate;

else h-= rate;

}else if(e.getSource ()==smaller){//缩小

if(w0) w-= rate;

else w+= rate;

if(h0) h-= rate;

else h+= rate;

}else if(e.getSource ()==rotate){//翻转

if(w0h0){

h*=-1;

}else if(w0h0){

w*=-1;

}else if(w0h0){

h*=-1;

}else if(w0h0){

w*=-1;

}

}else{//退出

System.exit(0);

}

photo.repaint ();//重新绘制

}

class Photo extends Canvas{

public void paint(Graphics g){

int width = this.getWidth();

int height = this.getHeight();

//设置图片左上角坐标

int x = (width-w)/2;

int y = (height-h)/2;

//绘制图片

g.drawImage(image, x, y, w, h,this);

}

}

}

三、补充:1、滚动面板功能没有具体实现2、放大缩小率应该按照图片宽高比来设置,最好用一个滚动条来放大缩小3、翻转功能需要改进 楼主自己试着完善下...

请问各位高手,我做了一个java wb 网站,是基于Struts2的,现在有个模块没能实现,哪位能帮我一下。

table border="2" cellpadding="10" cellspacing="10"

tr

%

int i = 0;

Listphototypes l = new ArrayListphototypes();

l = (Listphototypes) request.getAttribute("grouplist"); // 上一页点击查看相册 后台action函数生成的相册的列表

%

s:iterator value="grouplist"

%

String s = l.get(i).getGroupName(); //获得组名字

int groupId = l.get(i).getId();

i++;

%

!--也可以这样获得组名字:s:property value="groupName"/ --

s:form id="form" action="showAction.action" method="post" theme="simple"

input type="hidden" name="imgGroup" value=%=groupId % /

!--下面是组上面的封面 你可以自己定义一组,--

td align="center" width="100"

style="background-image: url('img/bg5.gif'); color: white; font-size: 16pt;" onmouseover="this.style.cursor='hand'"

%=s%

br

!--点击查看 触发这个form action 向后台传入相册的id,后台action根据相册id找到相册里照片的列表,跳转到相片显示的页面显示--

input type="submit" value="check" /

/td

/s:form

%

if (i % 3 == 0) {

%

/trtr

%

}

%

/s:iterator

/tr

用javaweb怎样制作相册?

用jspSmartUpload组件来实现,用jsp+servlet在Servlet里实现的代码:

PrintWriter out = response.getWriter();

int count = 0;

// 实例化上传控件对象

SmartUpload su = new SmartUpload();

// 初始化操作

su.initialize(config, request, response);

// 设置上传文件最大字节数

su.setTotalMaxFileSize(100000);

//

try {

//禁止上传指定扩展名的文件

su.setDeniedFilesList("ext,bat,jsp");

} catch (SQLException e1) {

e1.printStackTrace();

}

try {

// 上传文件到服务器

su.upload();

File fileup = new File(request.getRealPath("upload"));

if(!fileup.exists()){

// 创建目录

fileup.mkdir();

}

// 处理多个文件的上传

for(int i = 0;i su.getFiles().getCount();i++){

com.jspsmart.upload.File file = su.getFiles().getFile(i);

if(!file.isMissing()){ // 如果文件有效

// 保存文件到指定上传目录

file.saveAs("/upload/new."+file.getFileExt(), su.SAVE_VIRTUAL);

count = su.save("/upload");

}

}

} catch (SmartUploadException e) {

e.printStackTrace();

}

out.println(count +"file(s) uploaded");

如果你对这个上传组件不了解,最好是先去查查用法。。。

如何用 java 做出 安卓手机 的 相册? (像‘人人’一样的)

当然是J2ME了,首先找个本子和比笔,把你要实现的事物对象分清楚,功能模块划分好,写详细一点,多少主类,其中的变量等其他东西是什么属性,建立一个接口把方法都抽象起来……一步一步来,不管你是哪个级别,查资料花时间是必须的……祝你早日写出来

java,web电子相册源码

我这有几套基于javaweb的电子相册源码, 基础功能都有实现

项目基于springmvc+spring+mybatis进行实现, BS架构, MVC设计模式分层实现, 数据库采用mysql 还是比较简单的

JAVA根据文件后缀名分类文件,并且将文件复制到不同的文件夹,求这段代码的注释

以下都是one by one letter打的,不容易,给点分吧。

import java.io.File;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import javax.swing.JFileChooser;

/**

* 1.选择被复制的源目录:sourcePath

* 2.选择文件被复制后存放的目标目录:targetPath

* 3.文件后缀名分类文件,并且将文件复制到不同的文件夹

*

*/

public class FileDemo {

/**

* 启动方法

* @param args

*/

public static void main(String[] args) {

/**

* 选择被复制的源目录:sourcePath

*/

File sourcePath = getSourcePath();

/**

* 选择文件被复制后存放的目标目录:targetPath

*/

File outputPath = getOutputPath();

/**

* 执行复制操作

*/

handlePath(sourcePath, outputPath);

}

/**

* 处理文件分类复制

* @param sourcePath

* @param outputPath

*/

private static void handlePath(File sourcePath, File outputPath) {

if (sourcePath == null || outputPath == null) //1.如果没有选择源目录或目标目录,则返回

return;

for (File file : sourcePath.listFiles()) { //2.取得源目录下所有的文件或文件夹,并进行遍历

if (file.isDirectory()) {

//3.如果当前遍历的是文件夹,则使用递归调用,继续处理该文件夹下面的所有文件或文件夹

handlePath(file, outputPath);

} else {

//4.如果当前遍历的是不是文件夹而是文件,那么直接开始copy的操作

//4.1.取得文件的文件名,包含文件后缀名

String fileName = file.getName();

if (fileName.contains(".")) {

//4.2.1.如果该文件有后缀名,即包含“.”点符号,则取得文件的后缀名为:最后一个点符号后面的字符串

String suffix = fileName.substring(fileName.lastIndexOf('.') + 1);

//4.2.2.根据文件最后的输出的目标目录和文件的后缀名,执行copy的操作(因为最后输出格式为按文件的后缀名分类,即最后输出如:pdf目录下面有pdf文件,txt目录下面有txt文件)

copy(file, new File(outputPath, suffix));

} else {

//4.3.如果该文件没有后缀名,即不包含“.”点符号,则直接在文件最后的输出的目标目录下建立“nosuffix”目录,执行copy的操作,将没有后缀名的文件复制到nosuffix目录下

copy(file, new File(outputPath, "nosuffix"));

}

}

}

}

/**

* 单个文件复制操作

* @param sourceFile

* @param targetDir

*/

private static void copy(File sourceFile , File targetDir){

System.out.println("copying " + sourceFile);

//1.如果目标目录不存在,则新建,此处的目标目录为按文件后缀名命名的目录,如pdf目录,txt目录以及nosuffix目录

if(!targetDir.exists()){

targetDir.mkdir();//新建目录

}

try {

//2.将源文件读取到输入流中

FileInputStream fis = new FileInputStream(sourceFile);

//3.按照目标目录和文件名构建文件输出流

FileOutputStream fos = new FileOutputStream(new File(targetDir , sourceFile.getName())) ;

//4.定义缓冲区,大小为102400byte

byte[] buf = new byte[102400];

//5.定义输入流读取到的文件大小,下面会用到

int available = 0;

//6.fis.available():使用输入流fis读取当前文件的大小,将读取到的大小赋值给available

while((available = fis.available()) buf.length){

//7.如果当前读取到的大小available大于定义的缓冲区的大小102400,则用fis.read(buf)方法读取文件。

//此时,缓冲区buf会被完全读满,即源文件的前102400 byte的数据都会被读取到buf中,

//fis下一次读取就会从102401 byte开始读,即文件读取的开始位置移动到了available+1的位置上

fis.read(buf);

//8.使用文件输入流fos将缓冲区buf中的内容写入到目标文件中

fos.write(buf);

}

//9.上面的循环始终会结束,因为文件的大小不可能无限的大,当上面循环的判断使用fis.available()读取到当前剩余的文件大小小于102400 byte时,

//使用fis.read(buf, 0, available)将剩余的文件数据读取的buf对应的位置,

//例如,最后剩下的文件数据大小为100 byte,即available的值为100,那么使用执行方法fis.read(buf, 0, available),后,

//buf数组中的buf[0]到buf[99]会有数据,buf[100]之后的就都是空了。

fis.read(buf, 0, available);

//10.调用输出流fos.write(buf, 0, available)表示将buf中的前available大小的数据输出,

//例如上面举得例子,就只会将buf中的前100位数据输出。

fos.write(buf, 0, available);

fis.close();

fos.close();

} catch (Exception e) {

e.printStackTrace();

}

}

/**

* 弹出文件选择对话框,选择要被复制的源目录

* @return

*/

private static File getSourcePath(){

//1.弹出文件选择对话框

JFileChooser chooser = new JFileChooser();

//2.设置只能选择目录

chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

//3.返回选择的目录,如果没有选择则返回null

if(chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION){

return chooser.getSelectedFile();

}

return null;

}

/**

* 弹出对话框,选择文件复制后存放的目标目录

* @return

*/

private static File getOutputPath(){

//1.弹出文件选择对话框

JFileChooser chooser = new JFileChooser();

//2.设置只能选择目录

chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

//3.返回选择的目录,如果没有选择则返回null

if(chooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION){

return chooser.getSelectedFile();

}

return null;

}

}


网站题目:分类相册java代码 JAVA分类打印的代码要求依次输出
URL链接:http://bjjierui.cn/article/docijde.html

其他资讯