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

Tip: Looking for answers? Try searching our database.

UI Change at runtime affecting JButtonBar

Thread view: 
Dave Brown - 14 Jul 2005 17:21 GMT
Hi All,

Anyone any ideas why this is happening to me ?

I have a frame with various panels all GridBagLayout, one being on the
left containing a JButtonbar, with 4 buttons all stacked on top of each
other again GB Layout..

Everything is cool, but when I call my Change Appearence dialog and
select a new skin, as soon as I call

SwingUtilities.updateComponentTreeUI(this.getParent());

in the dialog to update the application with the new lookandfeel the
JBUttonBar layout changes..

Instead of the buttons being

X

X

X

X

they are now

XXXX

Any ideas anyone ?  It's really got me stumped :'(

Thanks in advance,

Dave.
Thomas Hawtin - 14 Jul 2005 21:44 GMT
> Everything is cool, but when I call my Change Appearence dialog and
> select a new skin, as soon as I call
[quoted text clipped - 17 lines]
>
> XXXX

The obvious thing would be for the PL&F to set it's own layout (without
checking if it is a UIResource).

Looking in JToolBar.updateUI there is a comment that the GTKLookAndFeel
is differently behaved.

Tom Hawtin
Dave Brown - 14 Jul 2005 22:03 GMT
>> Everything is cool, but when I call my Change Appearence dialog and
>> select a new skin, as soon as I call
[quoted text clipped - 25 lines]
>
> Tom Hawtin

Hi Tom,

Whats odd is that when I set the UI L&F before and frames are displayed
then the JToolBar comes up fine just as designed, the problem only
appears to occur when I do the
SwingUtilities.updateComponentTreeUI(this.getParent());

Although when I set the UI L&F before any frames are displayed I dont
actually have to call
SwingUtilities.updateComponentTreeUI(this.getParent());

rgds,

Dave.
Thomas Hawtin - 14 Jul 2005 22:32 GMT
> Whats odd is that when I set the UI L&F before and frames are displayed
> then the JToolBar comes up fine just as designed, the problem only
[quoted text clipped - 4 lines]
> actually have to call
> SwingUtilities.updateComponentTreeUI(this.getParent());

I guess the UI gets installed somewhere within addNotify.

Tom Hawtin
Signature

Unemployed English Java programmer

Andrew Thompson - 14 Jul 2005 22:44 GMT
[snip]
> Whats odd is that when I set the UI L&F before ..

I think example code would serve better than descriptions.
<http://www.physci.org/codes/sscce.jsp>

Signature

Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
Filmed on Location

Thomas Hawtin - 14 Jul 2005 23:46 GMT
> [snip]
>
>>Whats odd is that when I set the UI L&F before ..
>
> I think example code would serve better than descriptions.
> <http://www.physci.org/codes/sscce.jsp>

Well, here's some code showing a random case of PL&F playing nasty with
a LayoutManager. (It is technically dependent on the PL&F in use.)

import javax.swing.*;

class UILayoutManagerBug {
    public static void main(String[] args) {
        JList comp = new JList();
        SpringLayout layout = new SpringLayout();
        comp.setLayout(layout);
        comp.updateUI();
        if (comp.getLayout() != layout) {
             System.err.println("Wrong LayoutManager");
        }
    }
}

I'll just go and file a bug to the effect that PL&F should
(consistently) use the UIResource idiom for LayoutManagers.

Tom Hawtin
Signature

Unemployed English Java programmer



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.