This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Frame.getLocation() slow to update - need realtime position

 
Ranch Hand
Posts: 44
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a component that I want to move when someone moves a parent AWT frame. I want the component to seemlessly follow the frame, as if they were one. However, getting the location of the frame is not seemless, it's jerky. Adding a ComponentListener with a componentMoved also has this same jerky I moved, second later, I moved again. I want the position of the Frame to be updated every frame, instead of when I stop moving, so that I get the positions in between and can setLocation() on the other component.

Any way to get the accurate location through the entire move process so I don't get this jerky effect?
 
Sheriff
Posts: 21802
104
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't get that problem with the following example code:
 
Jeff Gent
Ranch Hand
Posts: 44
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get the issue with your code as well. The frames don't move in realtime together. If I grab the frame and wildly move it around the screen, the second frame doesn't move into position until I stop moving the first frame. I need both frames to move as one.

Mac OS X 10.7
 
Rancher
Posts: 3072
24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I get the issue with your code as well.



Rob's code works fine for me. I'm using JDK6_7 on XP.

If you have a problem then its probably a version or platform problem.

I'm guessing a platform problem. Maybe the componentMoved() event doesn't fire until the mouse is released?
 
Jeff Gent
Ranch Hand
Posts: 44
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not on mouse release. It's when the frame stops moving. I can still have the mouse held, drag it some more. Each time I stop, the other frame will jump to position. If I spin the frame in circles, the second frame just sits there, until I stop, then jumps to position. Weird
 
Rob Camick
Rancher
Posts: 3072
24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So why didn't you post you JDK version and platform???

Maybe someone else who has the same setup will test your code to see if they have the same problem or can provide a solution.

Edit:

Must be going blind, I missed the platform comment.
 
Jeff Gent
Ranch Hand
Posts: 44
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I stated above that I'm running Mac OSX 10.7 (Lion). It has the latest JRE for that OS, which is 1.6.0_26.
 
Jeff Gent
Ranch Hand
Posts: 44
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tested it on Windows 7 running 1.6.0_26 and had no issues, so thus far, it's a problem on the Mac.
 
Jeff Gent
Ranch Hand
Posts: 44
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems I'm not the only one, but I haven't seen a fix, though some suggested trying to capture mouseDragged. Guess it's been an issue on the Mac for a while, seems to be reported as "regression bug, 7731968", though I can't check it.

http://markmail.org/message/mxcextifjdn4xuq3
http://lists.apple.com/archives/java-dev/2003/Mar/msg01484.html
http://stackoverflow.com/questions/757078/events-for-window-dragging-in-java
http://stackoverflow.com/questions/3035054/getting-a-jframes-actual-current-location
 
Today you are you, that is turer than true. There is no one alive who is youer than you! - Seuss. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!