Skip to main content

Are Painters "aware" of focus?

2 replies [Last post]
danielrech
Offline
Joined: 2006-08-30
Points: 0

I would like to know if a Painter has awareness of the component using it having focus or not?

I need to paint an image behind a button only when it is selected. What would be a good to implement this?

The only solution I have found so far is to replace the button's bgImage in the Form's paint method, but then I need to call repaint() inside the paint(), which sounds a bit messy to me. Or is it OK?

Thanks in advance.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
joersch
Offline
Joined: 2008-11-06
Points: 0

i implement the same in my project. I extended the button class and set the new styles.
With the newes release of lwuit you can
setSelectedStyle
setUnSelectedStyle

Additionally i set a third style, if the button is pressed. I define a style, load this style in the constructor and assign it in keyPressed method. In the keyReleased method, i restore the origin selected Style.

It is a realy good visually effect.

Klemens

You can setBgPainter() and only paint the image if the Button hasFocus()
&& isFocusPainted(). The Painter itself is not aware, but the Button is.

On 08.04.2009 21:15, lwuit-users@mobileandembedded.org wrote:
> I would like to know if a Painter has awareness of the component using it having focus or not?
>
> I need to paint an image behind a button only when it is selected. What would be a good to implement this?
>
> The only solution I have found so far is to replace the button's bgImage in the Form's paint method, but then I need to call repaint() inside the paint(), which sounds a bit messy to me. Or is it OK?
>
> Thanks in advance.
> [Message sent by forum member 'danielrech' (danielrech)]
>
> http://forums.java.net/jive/thread.jspa?messageID=341214
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>
>
>

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