aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes real time movement for container Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "real time movement for container" Watch "real time movement for container" New topic
Author

real time movement for container

Johannes Lueder
Greenhorn

Joined: Sep 10, 2012
Posts: 7
Hello everybody.

I am building a gui within an applet, which does have an animation and updates frequently. Therefore to prevent redrawing overlaying UI components of the animating component, i have set up a few JDialogs. These need to become relocated as the "main frame" gets moved/dragged. In order to deal with that, i have registered a componentlistener to the owner frame of the applet. Unfortunately it feels like the componentMoved event does not get called realtime. Therefore as i do move the main frame, the dialogs are moving a little bit slower, which just looks ugly. I was wondering, if there is any possibility to register/override mouseDragged of the Titilebar and extend it by my location update. It just seems that componentMoved is slightly to slow.

Here is some code:





Thanks for help.
Best regards.
tuedel
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38910
    
  23
Please beware of long lines; I have shortened some in your code.
Johannes Lueder
Greenhorn

Joined: Sep 10, 2012
Posts: 7
Nobody has an idea?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> It just seems that componentMoved is slightly to slow.

do you realize that componentMoved will fire 2-300 times in a short space?
Johannes Lueder
Greenhorn

Joined: Sep 10, 2012
Posts: 7
Hm well, i havent yet counted how often the componentMoved event get triggered per time. So you would guess, that i do update my UI to often and therefore i might have a slight lag due to to bulk updates?!
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4547
    
    5

Moving any heavyweight component will always be visibly laggy, and top-level windows are heavyweight.

But I'm still trying to figure out how you are
building a gui within an applet
but
the "main frame" gets moved/dragged
or why you feel you need to
prevent redrawing overlaying UI components of the animating component
Redrawing/repainting lightweight components will always be faster than relocating/moving heavyweight ones.


luck, db
There are no new questions, but there may be new answers.
Johannes Lueder
Greenhorn

Joined: Sep 10, 2012
Posts: 7
Well dragging the browser is not really common. Usually the application becomes started, without interacting with the browser that much. Therefore relocating these heavyweight components is not used to happen often.

My Problem is, that an animation is drawn approximately 25x per second. The problem of his conception is, that any lightweight component i do place above the Panel, where the animation is drawn into, need to become redrawn as well, otherwise only the animation would be visible on screen. I have tried to handle that problem with Glasspane, LayeredPane or Clipping within the Graphics procedure. In any case - the lightweight components above become redrawn as often as my animation needs to become updated. Thatswhy i have made use of heavyweight components. Some may say, that redrawing of a few lightweight components should not be that expensive, but i do have a JList, which does a lot of String operations and therefore has a massive impact on the cpu usage. On common computer this leads to an 30% increased cpu usage, just having the Jlist visible/invisible.

If somebody has an alternative to the heavyweight components i do use currently, i would be very thankful. I haven't found any fine solution using lightweight components within the same heavyweight container, without being forced to redraw everything frequently.

Thanks.
Best regards.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> I have tried to handle that problem with Glasspane, LayeredPane or Clipping within the Graphics procedure.

JPanel set as OverlayLayout ?
Johannes Lueder
Greenhorn

Joined: Sep 10, 2012
Posts: 7
Heya haven't heart of the overlayLayout yet. I am given a try to that one. I will tell you, if this has worked out. Thanks for now.
Johannes Lueder
Greenhorn

Joined: Sep 10, 2012
Posts: 7
Hello,

after having tried to make use of the overlayLayout, it also has turned out, that the component, which needs to become redrawn on the very bottom, also calls the overlaying components paintcomponent method. Therefore if i haven't overridden the isOptimizedDrawingOptimized, the overlaying components do not become "overdrawn" and aren't visible on screen. Therefore seems like overlayLayout does not fix my issue.

Here my source code for the overlayLayout:

 
 
subject: real time movement for container