Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

directory structure

 
kalai sundar
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my problem is

int fc=FileChooser.showOpenDialog(this);
if(fc==0)
{
fil=FileChooser.getCurrentDirectory();
String str=fil.getAbsolutePath();
txtFileLoc.setText(str);
}
when i use the above mention code, i am editing the directory path as for eg
e:\sample\new.class.But i don't want like that, i want to edit as e:\sample, But i coudn't vat should i do. plz hepl me

kalai
 
Joe Ess
Bartender
Pie
Posts: 9259
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you want to select a directory? Looking at the Java API documentation for javax.swing.JFileChooser, you'll see there's a method setFileSelectionMode:

public void setFileSelectionMode(int mode)

Sets the JFileChooser to allow the user to just select files, just select directories, or select both files and directories. The default is JFilesChooser.FILES_ONLY.

Parameters:
mode - the type of files to be displayed:

* JFileChooser.FILES_ONLY
* JFileChooser.DIRECTORIES_ONLY
* JFileChooser.FILES_AND_DIRECTORIES

Throws:
IllegalArgumentException - if mode is an illegal file selection mode
See Also:
getFileSelectionMode()

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic