>> Just write your own button. This is really easy with a JPanel and a
>> MouseListener.
[quoted text clipped - 8 lines]
> addActionListener method, which is why I went with the JToggleButton.
> Looks like I may have to rethink that.

Signature
Knute Johnson
email s/nospam/linux/
On May 8, 10:43 am, Knute Johnson <nos...@rabbitbrush.frazmtn.com>
wrote:
<snip>
> Do you need keyboard input, is that why you want an ActionListener?
No, I don't need keyboard input. I just envisioned it reacting like a
button, and figured that it was easier to subclass JToggleButton than
reinvent the wheel. Of course, when I decided to subclass
JToggleButtion, I wasn't aware of the behavior that prompted my
original post. I discovered that by accident.
> Why
> don't you explain completely what you want your button to do?
I did. It represents a "card" in the Memory game - sometimes called
'Concentration' after the TV show based on the Memory game. When
someone clicks on the "card" it is "turned over" to reveal the face.
Since JToggleButton already had the ability to hold two images - one
which could be the back of the card and the other the fact - it seemed
like a obvious choice. But as I said earlier, I wasn't aware of the
behavior that prompted this thread.
Since nobody else has chimed in with a way to override that behavior,
I have to assume that nobody is aware of any way to do so. (Which may
mean that there isn't any way.) So it looks like I "roll my own" and
subclass JPanel.
John B. Matthews - 11 May 2008 17:48 GMT
In article
<cd26e5b0-3633-4c3f-934b-404d4edeb754@t54g2000hsg.googlegroups.com>,
[...]
> I did. It represents a "card" in the Memory game - sometimes called
> 'Concentration' after the TV show based on the Memory game. When
[quoted text clipped - 8 lines]
> mean that there isn't any way.) So it looks like I "roll my own" and
> subclass JPanel.
I think it's the ToggleButtonModel that's responsible for the behavior.
Why not instantiate JToggleButton and set the model to an extension of
DefaultButtonModel that overrides isArmed().
John

Signature
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews
Redbeard - 12 May 2008 02:58 GMT
> In article
>
[quoted text clipped - 22 lines]
> trashgod at gmail dot com
> home dot woh dot rr dot com slash jbmatthews
Sounds like an idea that is worth a try. Thanks!
John B. Matthews - 12 May 2008 13:42 GMT
In article
<64bb689b-59ba-4f2a-8109-408cc671f0f6@34g2000hsh.googlegroups.com>,
> > In article
> > <cd26e5b0-3633-4c3f-934b-404d4edeb...@t54g2000hsg.googlegroups.com>,
[quoted text clipped - 8 lines]
>
> Sounds like an idea that is worth a try. Thanks!
Sorry, I misspoke: set the model to an extension of ToggleButtonModel
that overrides isArmed(). I think you still want the "toggle" behavior,
just not the "armed" behavior. Also note: the button model fires both
ActionEvent (for pressed) and ItemEvent (for both selected and
deselected), as part of the "group" notion for check boxes and radio
buttons.
It might be cleaner to extend AbstractButton and DefaultButtonModel to
create, in effect, a JConcentrationButton. The custom model could
enforce rules like "no peeking" and "exposing a third card flips the
other two," etc.
John

Signature
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews