Skip to main content

Animated Focus Transition For Regular Components

2 replies [Last post]
cozmint
Offline
Joined: 2004-09-18
Points: 0

Hi,
There are some issues with the example from Shai's blog. I replaced components with 6 buttons and two comboboxes.
-if I keep pressing key up/down the first component get focused until the key is released
-at the bottom of the screen the motion focus overlap the menu bar
-all buttons have a painter for selected and unselected state. If a button which invoke a dialog is pressed and I'm fast enough (during the motion focus duration) I can move the motion focus to the next component. Only after the dialog is dismissed the component is painted by the selected painter and this give a strange look.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Shai Almog

Hi,
ideally comments specific to a blog post (even one referenced here)
should go in the blog. Please keep that in mind for the future
otherwise people won't find the answers when looking at the blog.

> Hi,
> There are some issues with the example. I replaced components with
> 6 buttons and two comboboxes.
> -if I keep pressing key up/down the first component get focused
> until the key is released

This is easily fixed by turning this:
} else {
super.setFocused(c);
}

Into this:
} else {
if(futureFocus == null) {
super.setFocused(c);
}
}

> -at the bottom of the screen the motion focus overlap the menu bar

We just need to add clipping for the content pane to solve this:
if(futureFocus != null) {
int oX = g.getClipX();
int oY = g.getClipY();
int oWidth = g.getClipWidth();
int oHeight = g.getClipHeight();
g.clipRect(getContentPane().getX(),
getContentPane().getY(), getContentPane().getWidth(), getContentPane
().getHeight());
g.setColor(futureFocus.getStyle
().getBgSelectionColor());
g.fillRect(focusMotionX.getValue(),
focusMotionY.getValue(),
focusMotionWidth.getValue(),
focusMotionHeight.getValue(),
(byte)140);
g.setClip(oX, oY, oWidth, oHeight);
}

> -all buttons have a painter for selected and unselected state. If a
> button which invoke a dialog is pressed and I'm fast enough (during
> the motion focus duration) I can move the motion focus to the next
> component. Only after the dialog is dismissed the component is
> painted by the selected painter and this give a strange look.

From the description it seems like reasonable behavior but I'm
having a bit of a hard time picturing this. If you don't think so
just send me a compilable test case.

> [Message sent by forum member 'cozmint' (cozmint)]
>
> http://forums.java.net/jive/thread.jspa?messageID=300312
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

cozmint
Offline
Joined: 2004-09-18
Points: 0

Thanks for advice.
That's a very elegant solution to the problem.