67,549
社区成员




public class TestDlg extends JFrame implements ActionListener {
private static final long serialVersionUID = -7495940408592595397L;
private JPanel mainPanel;
private Button b = new Button("设置目录");
public TestDlg() {
//设置框架初始化参数
this.setTitle("二代证读取");
this.setLocation(200, 50);
/*初始化工作开始*/
mainPanel = new JPanel(); //初始化主面板
//添加按钮监视事件
b.addActionListener(this);
//将按钮添加到主面板
mainPanel.add(b);
//将主面板加入框架
this.getContentPane().add(mainPanel);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(660, 500);
this.setVisible(true);
}
//此接口一定要继承StdCallLibrary 否则读卡错误!
public interface SynIDCardAPI extends StdCallLibrary {
SynIDCardAPI INSTANCE = (SynIDCardAPI)Native.loadLibrary("SynIDCardAPI", SynIDCardAPI.class);
public int Syn_SetPhotoPath(int iOption, char[] cPhotopath);
}
//继承自ActionListener
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if (source == b) {
String strInfo = new String();
JFileChooser fileChooser = new JFileChooser(".");
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fileChooser.setDialogTitle("打开文件夹");
int ret = fileChooser.showOpenDialog(null);
if (ret == JFileChooser.APPROVE_OPTION) {
//文件夹路径
System.out.println(fileChooser.getSelectedFile().getAbsolutePath());
char[] strTmp = fileChooser.getSelectedFile().getAbsolutePath().toCharArray();
int nRet = SynIDCardAPI.INSTANCE.Syn_SetPhotoPath(0,strTmp);
strInfo.format("照片存放路径设置为 %s,nRet = %d", strTmp, nRet);
}
else {
strInfo = "选取路径失败!";
}
System.out.println(strInfo);
}
else
System.out.println("Something else");
}
public static void main(String[] args) {
new TestDlg();
}
}
public class UnsatisfiedLinkError
extends LinkageError
当 Java 虚拟机无法找到声明为 native 的方法的适当本地语言定义时,
抛出该错误。