Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

real time movement for container

 
Johannes Lueder
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 48985
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please beware of long lines; I have shortened some in your code.
 
Johannes Lueder
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nobody has an idea?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> 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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5126
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Johannes Lueder
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> I have tried to handle that problem with Glasspane, LayeredPane or Clipping within the Graphics procedure.

JPanel set as OverlayLayout ?
 
Johannes Lueder
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic