<Swing Dev> Programmatically clicking a JLabel in a JList
Pete Brunet
peter.brunet at oracle.com
Sat Jun 11 05:11:22 UTC 2016
Thanks Andrej.
On 6/9/16 1:07 AM, Andrej Golovnin wrote:
> One more solution:
>
> MouseEvent clicked = ....
> JLabel l = ...
>
> for (MouseListener ml : l.getMouseListeners()) {
> ml.mouseClicked(clicked);
> }
>
> But this solution only works if you don't have subclasses of JLabel
> which override the #processMouseEvent(MouseEvent)-method.
>
> On Thu, Jun 9, 2016 at 7:44 AM, Andrej Golovnin
> <andrej.golovnin at gmail.com> wrote:
>> Hi Pete,
>>
>> you can either use java.awt.Robot or you can dispatch an event by
>> calling java.awt.Component.dispatchEvent(AWTEvent).
>>
>> Best regards,
>> Andrej Golovnin
>>
>> On Wed, Jun 8, 2016 at 10:46 PM, Pete Brunet <peter.brunet at oracle.com> wrote:
>>> To add some accessibility support I need to programmatically click a
>>> JLabel in a JList. If I can figure out the code path for when this
>>> happens with a real click I can probably do what I need to do but as of
>>> yet I haven't figured it out. Does anyone on the list know at least
>>> part of the code path?
>>>
>>> Thanks, Pete
More information about the swing-dev
mailing list