} 、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、我现在自己加了一个Test类来测试一下这段代码: public class Test { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scann scann = new Scann(); scann.show(); }} 这样调用没有效果,产生,应该是别的调用方式还是画一个方法试试呢。
、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.StringTokenizer;import javax.imageio.ImageIO;
import javax.swing.*;
import net.javajeff.jtwain.*;
public class Scann extends JApplet {
protected ImagePanel myPanel;
protected String Imagepath;
protected JButton scanning, check, upload, down;
protected JToolBar mtbar;
protected String filePath;
JScrollPane jscrollPane; public void init() { if (JTwain.init() == false) {
downfile();
JTwain.init();
} myPanel = new ImagePanel();
jscrollPane = new JScrollPane(myPanel,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
getContentPane().add(jscrollPane, BorderLayout.CENTER);
Dimension dim = new Dimension(500, 600);
setLocation(dim.height, dim.width);
setVisible(true);
Container cp = getContentPane(); mtbar = new JToolBar();
addbutton();
cp.add(mtbar, BorderLayout.NORTH);
setSize(800, 600);
//String filepath = getParameter("UPLOAD_PATH"); }
private void addbutton(){
scanning =new JButton();
scanning.setText("扫描");
scanning.addActionListener( new ScanningActionAdapter(this));
upload =new JButton();
upload.setText("上传");
upload.addActionListener( new UploadLoadFileActionAdapter(this));
mtbar.add(scanning);
mtbar.add(upload);
mtbar.addSeparator();
}private void downfile(){
String libraryPath = System.getProperty("java.library.path");
if ((libraryPath == null) || (libraryPath.trim().length() == 0)) {
JOptionPane.showMessageDialog (this,
"无法找到系统路径。");
return;
}
String systemDir = null;
String firstEntry = null;
String original;
String entry;
String sourceURL;
StringTokenizer st = new StringTokenizer(libraryPath, ";");
int i = 0;
while (i < st.countTokens()) {
original = st.nextToken();
entry = original;
if (i == 0) {
firstEntry = entry;
}
if (entry.endsWith("\\")) {
entry = entry.substring(0, entry.length() - 1);
}
entry = entry.toLowerCase();
if (entry.endsWith("windows\\system")) {
systemDir = original;
break;
}
if (entry.endsWith("winnt\\system32")) {
systemDir = original;
break;
}
if (entry.endsWith("windows\\system32")) {
systemDir = original;
break;
}
i++;
}
if (systemDir==null) {
systemDir = firstEntry;
}
String dllname=getParameter("DLL_NAME");
System.out.println("dll_name:"+dllname);
if ( dllname==null){
JOptionPane.showMessageDialog (this, "无法获取dll文件!");
return;
}
if (getParameter("DOWNLOAD_URL")==null){
JOptionPane.showMessageDialog (this, "无法找到下载路径!");
return;
}
sourceURL = getParameter("DOWNLOAD_URL");
File file = new java.io.File(systemDir, getParameter("DLL_NAME"));
try {
downloadFile(sourceURL,file);
} catch (IOException e) {
JOptionPane.showMessageDialog (this,
"下载失败,您所访问的资源不存在!");
e.printStackTrace();
}
}private void downloadFile(String sourceURL, java.io.File targetFile) throws java.io.IOException {
java.net.URL url;
java.net.URLConnection connection;
java.io.InputStream inputStream;
java.io.FileOutputStream outputStream;
java.io.BufferedInputStream in;
java.io.BufferedOutputStream out;
byte[] buffer;
int bytesRead;
url = new java.net.URL(sourceURL);
connection = url.openConnection();
inputStream = connection.getInputStream();
outputStream = new java.io.FileOutputStream(targetFile);
in = null;
out = null;
buffer = new byte[8192]; {
in = new BufferedInputStream(inputStream, buffer.length);
out = new BufferedOutputStream(outputStream, buffer.length);
bytesRead = 0;
while ((bytesRead = in.read(buffer)) != -1) {
out.write(buffer, 0, bytesRead);
}
in.close();
out.close();
}
}
}
、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、我现在自己加了一个Test类来测试一下这段代码:
public class Test { /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scann scann = new Scann();
scann.show();
}}
这样调用没有效果,产生,应该是别的调用方式还是画一个方法试试呢。