Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / February 2005

Tip: Looking for answers? Try searching our database.

How to apply look and feel to the whole application

Thread view: 
Alexey Litvinuke - 06 Feb 2005 19:31 GMT
My app has much of panels, forms etc. When applying different LAFs(Look and
feels)
not all the elements change their LAF. It conserns some buttons and panels
which are
integrate into other panels dynamically during working with application. How
can I apply LAF
(e.g. system default) to whole application?

NOTE: if I apply it directly to the component (JButton, etc) than it can get
new LAF. But here I have
very much of such components

Thanks in advance.
Steven T Abell - 06 Feb 2005 21:21 GMT
> How can I apply LAF (e.g. system default) to whole application?

Look at UIManager.setLookAndFeel().

Best regards,

Steve
Alexey Litvinuke - 06 Feb 2005 21:53 GMT
The porblem is that method doesn't apply it for whole app. As I mentioned in
original message
it applies it to most but not all the elements. :-/

>> How can I apply LAF (e.g. system default) to whole application?
>
[quoted text clipped - 3 lines]
>
> Steve
Roland - 06 Feb 2005 22:20 GMT
> The porblem is that method doesn't apply it for whole app. As I mentioned in
> original message
[quoted text clipped - 7 lines]
>>
>>Steve

SwingUtilities.updateComponentTreeUI(component);

You have to call it for every component that's not directly reachable
from your application's frame.

Signature

Regards,

Roland de Ruiter
  ___      ___
 /__/ w_/ /__/
/  \ /_/ /  \

xarax - 07 Feb 2005 01:21 GMT
>> The porblem is that method doesn't apply it for whole app. As I mentioned in
>> original message
[quoted text clipped - 12 lines]
> You have to call it for every component that's not directly reachable from
> your application's frame.

A typical way to do this for the main component to set
up a listener interface where the other components
can register themselves for LAF update events.

The main component, somehow, sets an API that allows
other components to register their listeners. Whenever
the main component decides to change the LAF, it calls
all of the registered listeners to notify them that they
need to update their LAF. The custom event message can
contain the necessary details of the LAF changes, if needed.
Thus, the main component does not need to know all of
the other components in the application. The other components,
however, must know how to register/un-register their listeners.
Thomas Fritsch - 07 Feb 2005 15:03 GMT
>> The porblem is that method doesn't apply it for whole app. As I
>> mentioned in original message
[quoted text clipped - 12 lines]
> You have to call it for every component that's not directly reachable
> from your application's frame.

Just one addition to what the previous posters pointed out: A handy way
to get all(!) frames of your app is the static Frame.getFrames() method.
  Frame frames[] = Frame.getFrames();
  for (int i = 0; i < frames.length; i++)
    SwingUtilities.updateComponentTreeUI(frames[i]);

Signature

"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')

Roland - 07 Feb 2005 16:36 GMT
>>> The porblem is that method doesn't apply it for whole app. As I
>>> mentioned in original message
[quoted text clipped - 18 lines]
>   for (int i = 0; i < frames.length; i++)
>     SwingUtilities.updateComponentTreeUI(frames[i]);

I wasn't aware of the existence of Frame.getFrames(). I used a similar
technique as mentioned by xarax. I think I'll go and see if it can be
replaced by getFrames() in my app.
Signature

Regards,

Roland de Ruiter
  ___      ___
 /__/ w_/ /__/
/  \ /_/ /  \

Karsten Lentzsch - 07 Feb 2005 19:18 GMT
> Just one addition to what the previous posters pointed out: A handy way
> to get all(!) frames of your app is the static Frame.getFrames() method.
>   [...]

See also Frame#getOwnedWindows.

- Karsten


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.