directory chooser problems

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

directory chooser problems

Jon Harman
Hi,

I'm running on a PC.
I added a routine to my plugin that has a directory open dialog using
the ImageJ directory chooser.  If the routine runs then the "look and
feel" of my swing components changes.  I see that the directory chooser
has a Java2.setSystemLookAndFeel() call.  Is this what screws up my
swing components?
I don't know much about getting and setting the look and feel.   How do
I save the lookandfeel  before the directory chooser call so that I can
restore it after the routine is finished?

This does not happen with a file open call.

Thanks for any help.
Jon
Reply | Threaded
Open this post in threaded view
|

Re: directory chooser problems

ctrueden
Hi Jon,

Yeah, a change to the L&F will change over all the components (or at
least all components from that point forward -- the behavior for
existing components is kind of strange).

You can get the current L&F by doing:

LookAndFeel laf = UIManager.getLookAndFeel();

Then call the directory chooser. Afterward, you can reset the L&F with:

UIManager.setLookAndFeel(laf);

HTH,
Curtis

On Jan 9, 2008 3:09 PM, Jon Harman <[hidden email]> wrote:

> Hi,
>
> I'm running on a PC.
> I added a routine to my plugin that has a directory open dialog using
> the ImageJ directory chooser.  If the routine runs then the "look and
> feel" of my swing components changes.  I see that the directory chooser
> has a Java2.setSystemLookAndFeel() call.  Is this what screws up my
> swing components?
> I don't know much about getting and setting the look and feel.   How do
> I save the lookandfeel  before the directory chooser call so that I can
> restore it after the routine is finished?
>
> This does not happen with a file open call.
>
> Thanks for any help.
> Jon
>
Reply | Threaded
Open this post in threaded view
|

Re: directory chooser problems

Jon Harman
Thanks Curtis,

That works, although one needs to add code to handle an exception:
           try { UIManager.setLookAndFeel(laf);}
           catch (UnsupportedLookAndFeelException e) {}

Jon
Curtis Rueden wrote:
 > Hi Jon,
 >
 > Yeah, a change to the L&F will change over all the components (or at
 > least all components from that point forward -- the behavior for
 > existing components is kind of strange).
 >
 > You can get the current L&F by doing:
 >
 > LookAndFeel laf = UIManager.getLookAndFeel();
 >
 > Then call the directory chooser. Afterward, you can reset the L&F with:
 >
 > UIManager.setLookAndFeel(laf);
 >
 > HTH,
 > Curtis
 >
 > On Jan 9, 2008 3:09 PM, Jon Harman <[hidden email]> wrote:
 >> Hi,
 >>
 >> I'm running on a PC.
 >> I added a routine to my plugin that has a directory open dialog using
 >> the ImageJ directory chooser.  If the routine runs then the "look and
 >> feel" of my swing components changes.  I see that the directory chooser
 >> has a Java2.setSystemLookAndFeel() call.  Is this what screws up my
 >> swing components?
 >> I don't know much about getting and setting the look and feel.   How do
 >> I save the lookandfeel  before the directory chooser call so that I can
 >> restore it after the routine is finished?
 >>
 >> This does not happen with a file open call.
 >>
 >> Thanks for any help.
 >> Jon
 >>
 >