图种生成器(v1.1),图种生成器v1.1,将种子文件(当然不只是种
分享于 点击 2887 次 点评:197
图种生成器(v1.1),图种生成器v1.1,将种子文件(当然不只是种
将种子文件(当然不只是种子文件)压缩,再利用图片文件生成图种,这样只需保存图片后,改图片后缀为压缩文件的后缀(如zip、rar等),就可以得到种子的压缩文件了.
示例:
将下图SeedCreate.PNG保存后,改文件后缀为zip,解压得本程序源文件
ps:贴吧常用此功能
import java.awt.Button;import java.awt.FileDialog;import java.awt.Frame;import java.awt.GridLayout;import java.awt.TextField;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;public class SeedCreate extends Frame { public static void main(String[] args) { new SeedCreate().launchFrame(); } public void launchFrame(){ final TextField tfSeedFile = new TextField("文件名和路径不能含有空格、逗号等字符"); final TextField tfImgFile = new TextField("文件名和路径不能含有空格、逗号等字符"); final TextField tfGetFilePath = new TextField(); Button seedFile = new Button("请选择压缩文件"); Button imgFile = new Button("请选择图片文件"); Button action = new Button("生成图种文件"); final FileDialog chooseSeedFile = new FileDialog(this,"选择压缩文件"); final FileDialog chooseImgFile = new FileDialog(this,"选择图片文件"); this.setLayout(new GridLayout(3,2)); this.add(seedFile); this.add(tfSeedFile); this.add(imgFile); this.add(tfImgFile); this.add(action); this.add(tfGetFilePath); seedFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { chooseSeedFile.show(); if(chooseSeedFile.getFile() !=null){ tfSeedFile.setText(chooseSeedFile.getDirectory()+chooseSeedFile.getFile()); } } }); imgFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { chooseImgFile.show(); if(chooseImgFile.getFile() != null){ tfImgFile.setText(chooseImgFile.getDirectory()+chooseImgFile.getFile()); } } }); action.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { Runtime r=Runtime.getRuntime(); try{ String imgFileName = chooseImgFile.getFile(); String seedFileName = chooseSeedFile.getFile(); if(imgFileName != null && seedFileName !=null){ String fileName = seedFileName.substring(0,seedFileName.lastIndexOf('.')) + imgFileName.substring(imgFileName.lastIndexOf('.')); String fileURL = chooseSeedFile.getDirectory() + fileName; String s="cmd /c copy /b " + chooseImgFile.getDirectory() + imgFileName + "+" + chooseSeedFile.getDirectory() + seedFileName +" " + fileURL ; r.exec(s); tfGetFilePath.setText(fileURL); }else{ tfGetFilePath.setText("出错啦!请先选择文件!"); } }catch(Exception e){ System.out.println("错误:"+e.getMessage()); e.printStackTrace(); } } }); this.setLocation(500, 250); this.setSize(470, 150); this.setVisible(true); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); }}//该片段来自于http://byrx.net
用户点评