JAVA目录选择框的解决办法
FileDialog只能选择文件而不能选择文件夹。JFileChooser又太大,不太好看,鼓捣了好一会终于解决了。
记录一下关键部分代码,以备查用。
final JButton choose=new JButton("选择存储文件目录");
final JTextField dir=new JTextField();
final JFileChooser chooser=new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
choose.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
int returnValue=chooser.showOpenDialog(SearchFrame.this);
if (returnValue==JFileChooser.APPROVE_OPTION) {
File file=chooser.getSelectedFile();
dir.setText(file.getAbsolutePath());
path=file.getAbsolutePath();
}else {
JOptionPane.showMessageDialog(null, "请手动输入目录");
return;
}
}
相关文档:
Java NIO API详解
在JDK
1.4以前,Java的IO操作集中在java.io这个包中,是基于流的阻塞(blocking)API。对于大多数应用来说,这样的API使用很方
便,然而,一些对性能要求较高的应用,尤其是服务端应用,往往需要一个更为有效的方式来处理IO。从JDK 1.4起,NIO
API作为一个基于缓冲区,并能提供非阻塞(non-blo ......
转自:http://www.blogjava.net/action/archive/2007/04/10/109574.html
http://www.javaeye.com/topic/232662
1.设置Cookie
1Cookie cookie = new Cookie("key", "value");
2cookie.setMaxAge(60); //设置60秒生存期,如果设置为负值 ......
//导出
String mysql="mysqldump -uroot -proot --opt databasename > d:/test.sql";
java.lang.Runtime.getRuntime().exec("cmd /c "+mysql);
//导入
String mysql="mysqladmin -uroot -proot create databasename";
java.lang.Runt ......
from Rxtx
This page is for general content regarding the use of rxtx. Feel free to add your own content.
Using RXTX In Eclipse
Deploying JAVA with RXTX
I wrote an app several months ago using javax.comm on windows. Sun has left me high and dry. rxtx help!
download ftp://ftp.qbang.org/pub/rx ......