Skip to main content

Any way to prevent L&F addOns to overwrite defaults ?

9 replies [Last post]
elkner
Offline
Joined: 2003-06-10
Points: 0

Hmm,

is there a way, to prevent the L&F-AddOns to overwrite UI defaults?

As far as I can see, the static initializer of a L&F-AddOn driven classes simply overwrites UIManager defaults :(. Isn't it possible, to check before overwrite ?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
elkner
Offline
Joined: 2003-06-10
Points: 0

Hi,
>
> > UIManager.put("JXTitledPanel.title.foreground",
> > new ColorUIResource(Color.WHITE));
...
> just thinking aloud here: the moment you mark an
> entry as UIResource any
> LF is supposed to overwrite it.

Hmm, may be I haven't understood the UI stuff completely: If I load a new L&F, first I wanna have the defaults (That's why I used UIColorResource). Than depending on the choosen L&F I apply required modifications and call the usual SwingUtilities.updateComponentTreeUI(frame).

Kleopatra

Hi Fred,

> Jens is right.
>
> LookAndFeelAddons will call UIManager.put(xxx, xxx) and this will
> override previously registered key/values.
>

no easy way out - after all that's the LF's job. The only thing I can
think of is that it doesn't replace if there's already a registered
value which is not a UIResource. Didn't check if that would help, though.

Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

elkner
Offline
Joined: 2003-06-10
Points: 0

Hi Janette,
>
> do they? As far as I remember, they _add_ values -
> could you elaborate a
> bit on your concrete problem (which properties, which
> addons)?

Yes, pretty simple - e.g. start an app, load your L&F of choice, and
UIManager.put("JXTitledPanel.title.foreground",
new ColorUIResource(Color.WHITE));
UIManager.put("JXTitledPanel.title.darkBackground",
new ColorUIResource(Color.RED));
UIManager.put("JXTitledPanel.title.lightBackground",
new ColorUIResource(Color.YELLOW));

next step is obvious: Create a JXTitledPanel ...

Kleopatra

Hi Jens,

>
>>do they? As far as I remember, they _add_ values -
>>could you elaborate a
>>bit on your concrete problem (which properties, which
>>addons)?
>
>
> Yes, pretty simple - e.g. start an app, load your L&F of choice, and
> UIManager.put("JXTitledPanel.title.foreground",
> new ColorUIResource(Color.WHITE));
> UIManager.put("JXTitledPanel.title.darkBackground",
> new ColorUIResource(Color.RED));
> UIManager.put("JXTitledPanel.title.lightBackground",
> new ColorUIResource(Color.YELLOW));
>
> next step is obvious: Create a JXTitledPanel ...

Hmm... not entirely sure if I understand what you want to do here - so
just thinking aloud here: the moment you mark an entry as UIResource any
LF is supposed to overwrite it. If you want your custom values to take
precedence over LF settings, simply don't mark them as such. This should
preserve your settings, once #144 is solved ...

... or maybe not. They are conserved on the level of the ui-delegate,
not on the level of the UIManager. An alternative might be to read the
values from the resourcebundle. Maybe depends on your context - what
exactly are you trying to do?

Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

Frederic Lavigne

Kleopatra wrote:
> Hi Jens,
>
>>
>>> do they? As far as I remember, they _add_ values -
>>> could you elaborate a bit on your concrete problem (which properties,
>>> which
>>> addons)?
>>
>>
>> Yes, pretty simple - e.g. start an app, load your L&F of choice, and
>> UIManager.put("JXTitledPanel.title.foreground",
>> new ColorUIResource(Color.WHITE));
>> UIManager.put("JXTitledPanel.title.darkBackground",
>> new ColorUIResource(Color.RED));
>> UIManager.put("JXTitledPanel.title.lightBackground",
>> new ColorUIResource(Color.YELLOW));
>>
>> next step is obvious: Create a JXTitledPanel ...
>
> Hmm... not entirely sure if I understand what you want to do here - so
> just thinking aloud here: the moment you mark an entry as UIResource any
> LF is supposed to overwrite it. If you want your custom values to take
> precedence over LF settings, simply don't mark them as such. This should
> preserve your settings, once #144 is solved ...

This is correct. Suppose #144 is fixed and does not overwrite settings
(i.e does not replace entries which are not UIResources), the above code
should be written:

UIManager.put("JXTitledPanel.title.foreground", Color.WHITE);
UIManager.put("JXTitledPanel.title.darkBackground", Color.RED);
UIManager.put("JXTitledPanel.title.lightBackground", Color.YELLOW);

One issue will remain for Strings - which have no UIResource counterpart.

-fred

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

Kleopatra

Hi Jens,

>
> is there a way, to prevent the L&F-AddOns to overwrite UI defaults?
>
> As far as I can see, the static initializer of a L&F-AddOn
> driven classes simply overwrites UIManager defaults :(.

do they? As far as I remember, they _add_ values - could you elaborate a
bit on your concrete problem (which properties, which addons)?

Thanks
Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

Frederic Lavigne

Jens is right.

LookAndFeelAddons will call UIManager.put(xxx, xxx) and this will
override previously registered key/values.

Kleopatra wrote:
> Hi Jens,
>
>>
>> is there a way, to prevent the L&F-AddOns to overwrite UI defaults?
>>
>> As far as I can see, the static initializer of a L&F-AddOn
>> driven classes simply overwrites UIManager defaults :(.
>
> do they? As far as I remember, they _add_ values - could you elaborate a
> bit on your concrete problem (which properties, which addons)?
>
> Thanks
> Jeanette
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
> For additional commands, e-mail: jdnc-help@jdnc.dev.java.net
>
> .
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

Frederic Lavigne

Oups, hit the Send button way too quickly.
I wanted to add: I'll create a new issue in IssueTracker.

-fred

Frederic Lavigne wrote:
> Jens is right.
>
> LookAndFeelAddons will call UIManager.put(xxx, xxx) and this will
> override previously registered key/values.
>
> Kleopatra wrote:
>> Hi Jens,
>>
>>> is there a way, to prevent the L&F-AddOns to overwrite UI defaults?
>>>
>>> As far as I can see, the static initializer of a L&F-AddOn
>>> driven classes simply overwrites UIManager defaults :(.
>> do they? As far as I remember, they _add_ values - could you elaborate a
>> bit on your concrete problem (which properties, which addons)?
>>
>> Thanks
>> Jeanette
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
>> For additional commands, e-mail: jdnc-help@jdnc.dev.java.net
>>
>> .
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
> For additional commands, e-mail: jdnc-help@jdnc.dev.java.net
>
> .
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

Frederic Lavigne

https://swingx.dev.java.net/issues/show_bug.cgi?id=144

I'll look into it.

Frederic Lavigne wrote:
> Oups, hit the Send button way too quickly.
> I wanted to add: I'll create a new issue in IssueTracker.
>
> -fred

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net