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
精彩评论