How can I record mouse motions over the entire window?

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4

48 Replies - 1519 Views - Last Post: 20 June 2020 - 09:37 AM Rate Topic: -----

#16 nicephotog   User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 34
  • Joined: 06-June 20

Re: How can I record mouse motions over the entire window?

Posted 07 June 2020 - 09:24 PM

I think DICLover has the right idea with a glass pane but that is simply a transparent layer with settings for component stack height and settings for the mouse reaction not dissimilar to layers in javascript-DHTML.
The best practice is each window or panel type of component should be written as a separate class "extended" from the panel window type you choose and the code of those classes be as independent as possible although they are added into other classes and window type components. e.g. yes each class should have a mouselistener of its own.
Was This Post Helpful? 1
  • +
  • -

#17 Sciuriware   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 83
  • Joined: 17-August 13

Re: How can I record mouse motions over the entire window?

Posted 08 June 2020 - 06:18 AM

View Postnicephotog, on 08 June 2020 - 05:24 AM, said:

I think DICLover has the right idea with a glass pane but that is simply a transparent layer with settings for component stack height and settings for the mouse reaction not dissimilar to layers in javascript-DHTML.
The best practice is each window or panel type of component should be written as a separate class "extended" from the panel window type you choose and the code of those classes be as independent as possible although they are added into other classes and window type components. e.g. yes each class should have a mouselistener of its own.

That's exactly what I did before and from now on.
There's some side effects but I can live with it.
In my 40 year career there's many problems that were never solved, sometimes by time pressure,
sometimes because no one of the team had a useful idea.
Since I retired I had to compromise. Feels good that sometimes we think in the same direction.
;JOOP!
Was This Post Helpful? 0
  • +
  • -

#18 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3698
  • View blog
  • Posts: 16,952
  • Joined: 20-September 08

Re: How can I record mouse motions over the entire window?

Posted 08 June 2020 - 06:43 AM

I'm confused. I thought that the tedium of making every single component a mouse listener is precisely what you wanted to avoid? (You might avoid a bit of that by subclassing each type of component) Plus the tedium of converting local coordinates to 'world' ones?
Was This Post Helpful? 0
  • +
  • -

#19 Sciuriware   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 83
  • Joined: 17-August 13

Re: How can I record mouse motions over the entire window?

Posted 08 June 2020 - 07:47 AM

View Postg00se, on 08 June 2020 - 02:43 PM, said:

I'm confused. I thought that the tedium of making every single component a mouse listener is precisely what you wanted to avoid? (You might avoid a bit of that by subclassing each type of component) Plus the tedium of converting local coordinates to 'world' ones?

You are right, that was the reason to come here and I concluded that the glasspane causes too many problems,
let alone that I refuse to build on obsolete methods that Oracle will drop at an inconvenient moment.
The days in which I spent all my time on research are over. Then, I got only two applications that must be completed
and both have only two panes that must be subclassed: not the end of the world.
;JOOP!
Was This Post Helpful? 0
  • +
  • -

#20 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15724
  • View blog
  • Posts: 62,994
  • Joined: 12-June 08

Re: How can I record mouse motions over the entire window?

Posted 08 June 2020 - 08:07 AM

View Postnicephotog, on 07 June 2020 - 11:24 PM, said:

I think DICLover has the right idea [...]


Just to be clear - the member's name is not 'DicLover' that just happens to be the current title. The name is above their avatar image and a bit to the left. In this case 'NormR'.
Was This Post Helpful? 0
  • +
  • -

#21 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3698
  • View blog
  • Posts: 16,952
  • Joined: 20-September 08

Re: How can I record mouse motions over the entire window?

Posted 08 June 2020 - 08:08 AM

Quote

let alone that I refuse to build on obsolete methods that Oracle will drop at an inconvenient moment.


Well you can solve all the deprecation problems (one) simply by changing getModifiers to getModifiersEx fwiw
Was This Post Helpful? 0
  • +
  • -

#22 Sciuriware   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 83
  • Joined: 17-August 13

Re: How can I record mouse motions over the entire window?

Posted 08 June 2020 - 08:50 AM

View Postg00se, on 08 June 2020 - 04:08 PM, said:

Quote

let alone that I refuse to build on obsolete methods that Oracle will drop at an inconvenient moment.


Well you can solve all the deprecation problems (one) simply by changing getModifiers to getModifiersEx fwiw

... and then it did not work any more. Let's rest it. I'm content with the separate-pane solution.
;JOOP!
Was This Post Helpful? 0
  • +
  • -

#23 NormR   User is online

  • D.I.C Lover
  • member icon

Reputation: 832
  • View blog
  • Posts: 6,392
  • Joined: 25-December 13

Re: How can I record mouse motions over the entire window?

Posted 08 June 2020 - 09:31 AM

Quote

want to record the mouse position over the entire mainframe of an application

What will the record of mouse positions be used for?
I have done a similar thing so I could write a Robot script to drive an application.
I created a transparent window that I dragged to cover all the key locations I wanted to record and then moved the cursor over the top of that transparent window to record the cursors' positions.
I posted a link to the origins of my code in post#10
Was This Post Helpful? 0
  • +
  • -

#24 Sciuriware   User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 83
  • Joined: 17-August 13

Re: How can I record mouse motions over the entire window?

Posted 08 June 2020 - 09:57 AM

View PostNormR, on 08 June 2020 - 05:31 PM, said:

Quote

want to record the mouse position over the entire mainframe of an application

What will the record of mouse positions be used for?
I have done a similar thing so I could write a Robot script to drive an application.
I created a transparent window that I dragged to cover all the key locations I wanted to record and then moved the cursor over the top of that transparent window to record the cursors' positions.
I posted a link to the origins of my code in post#10

Use one: a cursor follower, adding a picture to the arrow, indicating what will happen on a click,
this has now successfully been implemented in my applications,
Use two: searching in a JTree can select a node and make it current, but there is no highlighting
like when you click on a node. I have to create a robot to simulate manual selection.
No problem, I did such a thing some years before.
;JOOP!
Was This Post Helpful? 0
  • +
  • -

#25 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3698
  • View blog
  • Posts: 16,952
  • Joined: 20-September 08

Re: How can I record mouse motions over the entire window?

Posted 08 June 2020 - 10:00 AM

Quote

I posted a link to the origins of my code in post#10
You should have used the GlassPane ;)
Was This Post Helpful? 0
  • +
  • -

#26 NormR   User is online

  • D.I.C Lover
  • member icon

Reputation: 832
  • View blog
  • Posts: 6,392
  • Joined: 25-December 13

Re: How can I record mouse motions over the entire window?

Posted 08 June 2020 - 10:07 AM

Quote

You should have used the GlassPane ;)

Can a GlassPane be used to cover the PC's window and allow the contents of the Desktop or an open app be seen?
Was This Post Helpful? 0
  • +
  • -

#27 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3698
  • View blog
  • Posts: 16,952
  • Joined: 20-September 08

Re: How can I record mouse motions over the entire window?

Posted 08 June 2020 - 10:58 AM

Quote

Can a GlassPane be used to cover the PC's window and allow the contents of the Desktop or an open app be seen?

Oh, if you mean the whole desktop window of the OS, then no, it's just for the app's window (which of course could be full screen)
Was This Post Helpful? 0
  • +
  • -

#28 nicephotog   User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 34
  • Joined: 06-June 20

Re: How can I record mouse motions over the entire window?

Posted 08 June 2020 - 11:56 PM

java.awt.Toolkit tk = Toolkit.getToolkit();

noe get screensize e.t.c.
and then get a
java.awt.Cursor

then get the cursors position
Was This Post Helpful? 0
  • +
  • -

#29 nicephotog   User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 34
  • Joined: 06-June 20

Re: How can I record mouse motions over the entire window?

Posted 09 June 2020 - 12:10 AM

ALSO Use the core API docs for cursor position you want
java.awt.MouseInfo , and depending, also java.awt.GraphicsDevice and java.awt.GraphicsConfiguration.
Some of the above can also be got through JavaFX framework not just core.
Was This Post Helpful? 0
  • +
  • -

#30 NormR   User is online

  • D.I.C Lover
  • member icon

Reputation: 832
  • View blog
  • Posts: 6,392
  • Joined: 25-December 13

Re: How can I record mouse motions over the entire window?

Posted 09 June 2020 - 07:54 AM

Quote

then get the cursors position

Do you have the class and method to do that?
Was This Post Helpful? 0
  • +
  • -

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4