• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to send a mouse event to a component where cursor is?

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends

I am working on a touch screen project. I need to develop a touch screen keyboard for this application

I know how to send the mouse event to a specific component like JTextField

but I don't know, how to send a mouse event to a component where the cursor is.

Can you help me please, I really don't have any idea about.

Thanks

Farhad
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The KeyboardFocusManager getFocusOwner() method will return the component that currently has focus.
 
Farhad Rahmati
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Rob

Can you please please, provide more detail about it,

I mean about KeyboardFocus manager and it's method.

and how to implement it.

Thanks for your reply, I appriciate it.

Farhad
 
Rob Camick
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can start by reading the API for the class mentioned.
 
Farhad Rahmati
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay Thanks for this information

all I need, is a start point and I could find it.

Thanks
 
Farhad Rahmati
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI Rob,

Thanks for your information after reading and some search finally I manage to do it, but still a tiny problem. I hope you can help me solve it

first Let me tell you what I did.

first thing, I made a method called whoWasFocused() here is the code


then I called this method when each textBox is gainedFocused.
so finally when you click the buttons, it adds its text in to the a variable.


it works fine, but I am not sure if it is the way to do it. when you click the buttons, the cursor is not in the text field, because the button is focused
I want the cursor to be in the text field while you are pressing the buttons.

Thanks
 
Rob Camick
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I want the cursor to be in the text field while you are pressing the buttons.



When you create the button you need to use:

 
Farhad Rahmati
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thank you very much for your help

yea it's working now,

Thanks
 
Farhad Rahmati
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rob

what do you think, if I put the buttons in a separt window not focusable and cursor shoud be on the focused text box where the user wants.

something like Screen Key board in windows.
 
catch it before it slithers away! Oh wait, it's a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic