Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to change my CheckBoxTree from FileSystemView to File

 
Dan Kazemi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I am new in this forum, I home my question is not off-topic.
I am trying to use a CheckBoxTree that has been already created here: https://github.com/aterai/java-swing-tips/blob/master/FileSystemTreeWithCheckBox/src/java/example/MainPanel.java
The problem which this JTree is that is uses FileSystemView for the root directory and as far as I know it does not set any root directory. So I want to have the ability to give it a root directory. for example: So when the tree appears , it lists files and folders in the provided address, and not the entire system.

The code is available in the provided GitHub. I tried to replace all in constrictors and bodies with to make it working. It worked but ended up with errors such as not showing the file icons.

Can someone tell me how to modify it correctly or if there is any better way to convert FileSystemView to File?


Thanks.
 
Tony Docherty
Saloon Keeper
Posts: 3144
72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch,

I'll add this question to the Swing forum as you may get some good advice from there as well as this forum.

The problem which this JTree is that is uses FileSystemView for the root directory and as far as I know it does not set any root directory

I think you are misunderstanding what FileSystemView does. It is a view on the whole file system and this view is dependent on the OS it is running on. For example the 'root' directory on a Windows platform is different to the root directory on a Unix platform.

Can someone tell me how to modify it correctly or if there is any better way to convert FileSystemView to File?

You can't convert one to the other as they are very different things, however most of the methods in the FileSystemView class take a File object as the parameter so in all probability your code will just need changing to pass in a File object set to the correct location.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!