Skip to main content

Should the processEventXXX method should be in the UI? Why not in JXLayer?

4 replies [Last post]
jacek
Offline
Joined: 2003-08-22
Points: 0

Let's say I want to swap different UIs depending on whether let's say the component is focused or not.

But, since the processFocusEvent method is at the UI layer itself (not in JXLayer), that seems somewhat cumbersome to do. Basically instead of handling the focused gained/lost events in JXLayer, I have to do it in the current UI layer and then tell its parent (i.e. the JXLayer) to swap the UI to a different one.

Seems a bit illogical for the child to tell the parent to swap it for a different child. Shouldn't this be purely the responsibility of the parent (i.e. the JXLayer)?

P.S. Yes, I know you can do the scenario mentioned above just by switching the layer effects to use let's say BlurFilter. But let's say I want to do something bigger like switch from a LockableUI to an ImageOpUI, depending on an event...I can't seem to add any event listeners at the JXLayer to let it swap/handle any LayerUIs it has at its disposal...

Message was edited by: jacek

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
alexfromsun
Offline
Joined: 2005-09-05
Points: 0

> Let's say I want to swap different UIs depending on whether let's say the component is focused or not.



The idea behind JXLayer is - to wrap your component with it, and then implement everything you need it its UI delegate

so switching UI delegates when a components' state is changed -

sounds like an incorrect usage of JXLayer

you should create your custom LayerUI and implement painting for focused and unfocused components there

have a look at SimpleDemo.java from the demo package -

there is a UIDelegate which implements different decorations for the different button's states

Thanks

alexp

jacek
Offline
Joined: 2003-08-22
Points: 0

So I guess a proper solution would have to a "super" UI that can basically do everything: locked, ImageOp, etc. depending on my current need, correct?

If I take the LockableUI as a base and then just switch/change layer effects whenever I need them, that would be the correct approach, I presume?

P.S. JXLayer is great BTW, especially with the full Filters.jar...really nice work there Alex. I am thinking of seriously integrating with it for my Java SwingBuilder project:

http://code.google.com/p/javabuilders/

alexfromsun
Offline
Joined: 2005-09-05
Points: 0

>So I guess a proper solution would have to a "super" UI that can basically do everything: >locked, ImageOp, etc. depending on my current need, correct?

That's right, you implement Layer's UI depending on your current need

>If I take the LockableUI as a base and then just switch/change layer effects whenever I need them,
that would be the correct approach, I presume?


Yes, that's how I use LockableUI in the LockableDemo

by the way, make sure you updated jxlayer.jar,

I made some changes in the LockableUI yesterday



SwingBuilder looks interesting, I'd like to know more about that

let me know if you need support from other JavaDesktop guys from Sun

Thanks

alexp

jacek
Offline
Joined: 2003-08-22
Points: 0

The thing I need most is time :-)

I presume you know how challenging it is to develop an OSS project on your own time....