> the size of the clickable unchangable circle
Hi Andre,
this is the radiobutton-icon.
Below is a code-snippet.
Hope this helps
Frank
import javax.swing.*;
public class ButtonIconResolver {
/**
* extracted from BasicRadioButtonUI
* @param b
* @return
*/
public static Icon getIcon(JRadioButton b) {
ButtonModel model = b.getModel();
Icon icon = b.getIcon();
if (icon != null) {
if (!model.isEnabled()) {
if (model.isSelected()) {
icon = b.getDisabledSelectedIcon();
} else {
icon = b.getDisabledIcon();
}
} else if (model.isPressed() && model.isArmed()) {
icon = b.getPressedIcon();
if (icon == null) {
icon = b.getSelectedIcon();
}
} else if (model.isSelected()) {
if (b.isRolloverEnabled() && model.isRollover()) {
icon = b.getRolloverSelectedIcon();
if (icon == null) {
icon = b.getSelectedIcon();
}
} else {
icon = b.getSelectedIcon();
}
} else if (b.isRolloverEnabled() && model.isRollover()) {
icon = b.getRolloverIcon();
}
if (icon == null) {
icon = b.getIcon();
}
return icon;
} else {
return UIManager.getIcon("RadioButton.icon");
}
}
}
Andre Rothe - 25 Apr 2008 15:41 GMT
Hi Frank,
Thank you very much, it works! I had used a proximity of 10 px for the
radius, but it haven't worked for all tested L&F. With your snipped I
can get the radius from the icon width.
Thanks!
Andre
>> the size of the clickable unchangable circle
>
[quoted text clipped - 3 lines]
> Hope this helps
> Frank
> Hi,
>
[quoted text clipped - 3 lines]
> the size of the clickable unchangable circle (which size depends on the
> look and feel).
But why do you want to get that?
Remember that, the native behavior (for example, on the Mac and Windows)
of check boxes and radio buttons is that they are active if the icon OR
the text label is clicked. This behavior is, of course, highly useful
for user productivity, since it gives a much larger target to hit with
the mouse button. (See Fitt's law, e.g.,
<http://en.wikipedia.org/wiki/Fitts'_law>,
<http://www.asktog.com/basics/firstPrinciples.html>)
Mac users, in particular, would tend to notice that the behavior isn't
quite what they expected. But I suppose that this

Signature
Thomas A. Russ, USC/Information Sciences Institute
Andre Rothe - 26 Apr 2008 10:26 GMT
Hi Thomas,
I would like to paint some extra shapes in the panel with the radio
buttons, so I need to know, where are the borders of the button. I don't
show the label of the button, so I only have to know, how large is the
button to paint around it.
Thank you.
Andre
> But why do you want to get that?
Thomas A. Russ - 28 Apr 2008 22:46 GMT
> Hi Thomas,
>
> I would like to paint some extra shapes in the panel with the radio
> buttons, so I need to know, where are the borders of the button. I don't
> show the label of the button, so I only have to know, how large is the
> button to paint around it.
Hmmm. If the images for the button graphics are opaque, wouldn't it be
easier to just paint your additional shapes on the background first, and
then have the normal painting occur? Or do you have to tailor your
shapes to the existing button image?
> Thank you.
> Andre
>
> > But why do you want to get that?

Signature
Thomas A. Russ, USC/Information Sciences Institute