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 / October 2005

Tip: Looking for answers? Try searching our database.

using SkinLF to change application LF

Thread view: 
anikkar@gmail.com - 26 Oct 2005 23:02 GMT
Hi,

I am trying to integrate skinLF in my application, and I have it
loading, and everything is working, except for the fact that i can't
seem to get the LF to change for all open windows.

Lets say for example, I have a main dialog (which a combo box where the
user can choose the LF), and 3 or 4 other dialogs open, when the user
chooses an LF, only the main dialog changes the LF. the other dialogs
must be closed and then re-opened to see any changes. This is the code
I got from the SkinLF documentation:

SkinLookAndFeel.setSkin(SkinLookAndFeel.loadThemePack((String)themesCombo.getSelectedItem()));    SwingUtilities.updateComponentTreeUI(getRootPane());

To make my problem even more confusing, I have no idea what other
dialogs may be open, so I can't call
SwingUtilities.updateComponentTreeUI(getRootPane()); for each dialog.

Is there a way to somehow autmatically make every dialog/frame/etc that
is open to incorporate this change? Even ones that aren't visible?
(this is for the case of singleton dialogs)

thanks!
Thomas Fritsch - 26 Oct 2005 23:55 GMT
> I am trying to integrate skinLF in my application, and I have it
> loading, and everything is working, except for the fact that i can't
> seem to get the LF to change for all open windows.

[...]
> To make my problem even more confusing, I have no idea what other
> dialogs may be open, so I can't call
[quoted text clipped - 3 lines]
> is open to incorporate this change? Even ones that aren't visible?
> (this is for the case of singleton dialogs)

Yes, you can. See the answer in
http://groups.google.de/group/comp.lang.java.gui/msg/1dd711387454d973

Signature

"TFritsch$t-online:de".replace(':','.').replace('$','@')

anikkar@gmail.com - 26 Oct 2005 23:58 GMT
Thanks for the reply, but it seems that only refers to Frames, where
JDialogs are not inherited by frames. I checked to see if there is a
similar method for Dialogs, but i didn't see anything of the sort.

you have any ideas?
Thomas Fritsch - 27 Oct 2005 00:33 GMT
> Thanks for the reply, but it seems that only refers to Frames, where
> JDialogs are not inherited by frames. I checked to see if there is a
> similar method for Dialogs, but i didn't see anything of the sort.
>
> you have any ideas?

A Dialog or JDialog always has a Frame as its parent (or as grand-parent, or
as grand-grand-parent, or ...). See the javadoc of the dialog constructors.
And even if Java might allow you to construct a Dialog with a null parent,
then Java creates an invisble Frame behind the scenes to become the parent.
In short: the technique will catch all your dialogs, too.

Signature

"TFritsch$t-online:de".replace(':','.').replace('$','@')

anikkar@gmail.com - 27 Oct 2005 00:43 GMT
hmm...it doesn't seem to work, but i will continue to play with it.
anikkar@gmail.com - 27 Oct 2005 00:51 GMT
I seem to have found the problem, it doesn't seem to update the any
buttons (thats the only component i have noticed yet), until you mouse
over the button (which fires the mouseOverEvent), which in turn changes
the UI of the button (particulary it's bounds, i.e. rounded corners,
etc).
Roedy Green - 27 Oct 2005 07:01 GMT
>I seem to have found the problem, it doesn't seem to update the any
>buttons (thats the only component i have noticed yet), until you mouse
>over the button (which fires the mouseOverEvent), which in turn changes
>the UI of the button (particulary it's bounds, i.e. rounded corners,
>etc).

Does calling updateUI automatically revalidate/repaint all Frames?
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Thomas Fritsch - 27 Oct 2005 10:49 GMT
>>I seem to have found the problem, it doesn't seem to update the any
>>buttons (thats the only component i have noticed yet), until you mouse
[quoted text clipped - 3 lines]
>
> Does calling updateUI automatically revalidate/repaint all Frames?
It is kind of the other way round. Calling updateComponentTreeUI() on a
frame revalidates/repaints all its children, grand-children, ...

Calling
  SwingUtilities.updateComponentTreeUI(frame)
walks through this frame's component/container tree. For each JComponent
found it calls its updateUI() method.
All(?) subclasses of JComponent have a canonical implementation, like
for class JBlaBla:
  public void updateUI() {
    setUI((BlaBlaUI) UIManager.getUI(this));
  }
Subclasses of JComponent in their setUI(..) method typically call
super.setUI(..) so that finally JComponent.setUI(..) is called, which in
turn calls revalidate() and repaint().

Signature

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

Roedy Green - 27 Oct 2005 11:22 GMT
On Thu, 27 Oct 2005 09:49:00 GMT, Thomas Fritsch
<i.dont.like.spam@invalid.com> wrote, quoted or indirectly quoted
someone who said :

>Subclasses of JComponent in their setUI(..) method typically call
>super.setUI(..) so that finally JComponent.setUI(..) is called, which in
>turn calls revalidate() and repaint().
what I was getting at is whether you had to revalidate/repaint the
tree after using your code.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Thomas Fritsch - 27 Oct 2005 14:50 GMT
>>Thanks for the reply, but it seems that only refers to Frames, where
>>JDialogs are not inherited by frames. I checked to see if there is a
[quoted text clipped - 7 lines]
> then Java creates an invisble Frame behind the scenes to become the parent.
> In short: the technique will catch all your dialogs, too.

I did some tests with JFrames and JDialogs. Unfortunately I must
withdraw my above statement, and affirm the opposite. :-(
SwingUtilities.updateComponentTreeUI(frame) does *not* reach the frame's
dialogs. The dialogs keep their Look&Feel.
I don't know exactly why. Probably the frame/dialog relationship is
somewhat different from the normal parent/child relationship in containers.

Signature

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

Andrew Thompson - 31 Oct 2005 04:53 GMT
..
> I did some tests with JFrames and JDialogs. Unfortunately I must
> withdraw my above statement, and affirm the opposite. :-(
> SwingUtilities.updateComponentTreeUI(frame) does *not* reach the frame's
> dialogs. The dialogs keep their Look&Feel.

They don't have to.
<http://www.physci.org/codes/resize/fullwnd5.html>

The 'Input' dialog is non-modal, but it's PLAF changes when
you click the System/Metal radio button.

If Babu pops by, he might tell you the correct way to
do the same thing I achieved in that source*, but it has
slipped my mind at the moment..
<http://www.physci.org/codes/display.jsp?fl=/codes/resize/PlafChanger.java>

HTH
Roedy Green - 31 Oct 2005 09:59 GMT
On Mon, 31 Oct 2005 03:53:16 GMT, Andrew Thompson
<seemysites@www.invalid> wrote, quoted or indirectly quoted someone
who said :

><http://www.physci.org/codes/display.jsp?fl=/codes/resize/PlafChanger.java>

in that code you say:

Frame[] allFrame = f.getFrames();
87        for (int ii=0; ii<allFrame.length; ii++) {
88            if (f!=allFrame[ii]) {
89                // recursive call to catch all children
90                updateFrame(allFrame[ii]);
91            }
92        }

Is that really recursive?
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Andrew Thompson - 31 Oct 2005 12:05 GMT
> On Mon, 31 Oct 2005 03:53:16 GMT, Andrew Thompson
> <seemysites@www.invalid> wrote, quoted or indirectly quoted someone
[quoted text clipped - 13 lines]
>
> Is that really recursive?

That was the quirky bit that Babu noticed when he first saw
the code..

I thought it needed a recursive call to catch all instances
of frames, but that static method Frame.getFrames() (which
I have referenced in a way that suggests it is an instance
method - very bad!) returns all frames owned by the
application/applet, so the recursive call was unnecessary.

Or, in other words, though it is coded as a recursive
method, it should *not* be.
Roedy Green - 27 Oct 2005 06:58 GMT
On Thu, 27 Oct 2005 00:58:10 +0200, "Thomas Fritsch"
<i.dont.like.spam@invalid.com> wrote, quoted or indirectly quoted
someone who said :

>> Is there a way to somehow autmatically make every dialog/frame/etc that
>> is open to incorporate this change? Even ones that aren't visible?
>> (this is for the case of singleton dialogs)
>>
>Yes, you can. See the answer in
>http://groups.google.de/group/comp.lang.java.gui/msg/1dd711387454d973

for future reference, I have documented Thomas's technique at
http://mindprod.com/jgloss/laf.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Thomas Fritsch - 27 Oct 2005 16:16 GMT
>>Is there a way to somehow autmatically make every dialog/frame/etc that
>>is open to incorporate this change? Even ones that aren't visible?
>>(this is for the case of singleton dialogs)
>
> Yes, you can. See the answer in
> http://groups.google.de/group/comp.lang.java.gui/msg/1dd711387454d973

To update the Look&Feel not only of the frames, but also of their owned
dialogs, a little more effort is needed:
  Frame frames[] = Frame.getFrames();
  for (int i = 0; i < frames.length; i++) {
    SwingUtilities.updateComponentTreeUI(frames[i]);
    Window windows[] = frames[i].getOwnedWindows();
    for (int j = 0; j < windows.length; j++) {
      SwingUtilities.updateComponentTreeUI(windows[j]);
  }

Signature

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

anikkar@gmail.com - 27 Oct 2005 18:17 GMT
Thanks Thomas, that solved the problem.


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.