• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Disabling and Enabling Up One level button and new folder button in JFileChooser on some condition

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have some problem regarding enabling and disabling icons in JFileChooser

Problem 1:

I have created a file chooser as follows
JFileChooser fileChooser = new JFileChooser( "Test" );

I need to disable up Folder Icon for this directory as it is the top directory.
But when i create a new folder in the directory and tries to save files to new folder , i want to enable up Folder button.
And also i need to disable the drop down box for Save In.

Problem 2:

I need to disable the new Folder button after i created 2 recursive folders in Test Directory.. say Test/ New Folder 1 / New Folder 2. After i add New Folder 2 inside New Folder 1 , i want to disable the new Folder button. How to identify whether i have clicked new Folder button recursively two times..
NB: I can have any number of folders in test directory. But each folder can have only one sub folder inside it.

Is there any easy way to implement this.

Thanks in Advance,
Rishita

 
Sheriff
Posts: 22656
126
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps it is an easier idea to subclass FileSystemView and make it a wrapper around the default:
Perhaps you can override createNewFolder to restrict the sub folder levels as well; throw an IOException if it will be one level lower.
 
Rishita Vishnu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry . this dint work for me.

My piece of code is like this



So for first time up level folder will be disabled. but if i add new folder in Test directory and opens that new folder to save file, i want up level folder to be enabled.
 
Thanks tiny ad, for helping me escape the terrible comfort of this chair.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic