我们界面做好后,根据每个功能的需求去实现,现在先实现选择按钮的功能,如何选择文件,,且显示出来;
很简单,百度都有:
//文件选择路径实现
btn_Button_xuanzefile.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
JFileChooser jChooser = new JFileChooser();
jChooser.setDialogTitle("sssss");
int returnVal = jChooser.showOpenDialog(null);
java.io.File file =jChooser.getSelectedFile();
if (JFileChooser.APPROVE_OPTION == returnVal) {
//需要传入的参数
jTextField.setText(file.getAbsolutePath());
String strPath = file.getAbsolutePath();
System.out.println(strPath);
}
}
});
---------------------------------完,不明白的给我留言·······················