• 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

Dragging a JWindow

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have written some code to make a JWindow draggable by using mouse and mouse motion listeners and redrawing the window as the user drags it with the mouse. However, I'm running into some problems that I would like help on.
The problem seems to occur at random time intervals, but occurs with greater probability when the mouse is moved very rapidly while dragging the window. The window is redrawn just fine, but every now and then it has a sparodic behavior in how it gets drawn to the screen. It will re-draw on one part of the window, hide itself, then re-draw on another part of the window (NOT where the mouse cursor is dragging it), hide itself, re-draw on yet another part of the window (again, NOT where the mouse cursor is dragging it), etc, etc. It will do this for about a 1/2 second to one second before following the mouse cursor again.
Does anyone have any experience dragging JWindows? If so, I could use your help. Thanks!!
 
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like a problem that could be solved with double-buffering...this involves painting the new image to a storage area of memory before it is actually painted to the screen. The result is flicker-free animation, or in your case, hopefully smooth error-free repainting of the window. Do a search for double-buffering in the popular applet tutorials, and I'm sure you'll find out more details of how to implement the technique.
------------------
  • Ryan Burgdorfer
  • Java Acolyte in
  • Columbus, OH USA
 
Buckley Lee
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, I've tried double bufferring and that didn't seem to work. The window still had a little sparodic behavior in WHERE it gets re-drawn in relation to the mouse. I'm wondering if the window re-draws just can't keep up with the mouse events and thats the reason for the strange behavior?
Instead of dragging the JWindow, I'm now displaying a JFrame on top of the JWindow as the user begins to drag the JWindow. Currently I'm using the JWindow mouse events to control the movement of the JFrame, then upon release of the mouse button the JWindow is re-drawn on top of the JFrame. The JFrame DOES NOT have the sparodic re-draw behavior like the JWindow (when it gets dragged with mouse events), * BUT *, is it possible to hand off the mouse event to the JFrame so that the movement of the JFrame does not have to be controlled by the JWindow mouse events? Only ONE button press of the mouse is desired here.
I am wanting to use a JWindow in my application because the title bar on the JFrame/Frame is taking up too much desktop space.
Once again, thanks for any ideas.
Bucky
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic