开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜