开发者

java What action should be considerd for button using as a browse to attach file or directory

开发者 https://www.devze.com 2022-12-26 18:30 出处:网络
I make a JF开发者_高级运维rame form which contains two text fields and two buttons. I need this form works as

I make a JF开发者_高级运维rame form which contains two text fields and two buttons. I need this form works as when user clicks first button will browse to attach file and second button will browse to attach directory.

http://www.freeimagehosting.net/uploads/2556c33f29.png


For browse a specified file or directory you should use the JFileChooser class.

    JFileChooser fileChooser = new JFileChooser(".");
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // for directory
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); // for files
0

精彩评论

暂无评论...
验证码 换一张
取 消