Skip to main content

LockableUI painting problem when locked (continued thread)

8 replies [Last post]
divxdede
Offline
Joined: 2007-09-01

This thread continue this one : http://forums.java.net/jive/thread.jspa?threadID=44315&tstart=0

So, i wrote a new Test Case that consist of:

A LayerUI (LockableUI subclass) that render on the glassPane a JXBusyLabel.
This label can be moving up and down with controls provided by the frame.

The frame own another control for "lock" or "unlock" the LayerUI.

How produce the bug ?
move up and down without locking the LayerUI and all work fine.
Lock the UI and move up and down, you should see an old "rubber stamp" of the label at an older position.

[code]
package org.divxdede.swing.busy.issue2;

import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTree;
import javax.swing.SwingUtilities;
import org.jdesktop.jxlayer.JXLayer;

/**
* Reveal a painting issue using LockableUI
* @author Andr

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
alexfromsun
Offline
Joined: 2005-09-05

Hello Andre

When I run your test I didn't see any sign of the busy label on the layer's glassPane,
the reason may be the old version of SwingX I have on my computer.
Anyway, after you move a component on the layer's glassPane
you should mark the layer as dirty:

[code]
public void doUp() {
this.layout.incrOffset( -10 );
label.revalidate();
setDirty(true);
}
[/code]

The same is for doDown()

Thanks
alexp

divxdede
Offline
Joined: 2007-09-01

I will see if this tip help me.

Can you try with a newer version of swingX ? i use the 0.9.3 on my development platform.

If the glasspane is a complex container that have it's own ui logic and control.
When some of their childs is lay out (invalidate/revalidate), we must monitor it and call the setDirty() manually ?

Message was edited by: divxdede

divxdede
Offline
Joined: 2007-09-01

The setDirty() works fine.

But have you a tip for manage automatically a setDirty() on the layerUI when a dirty region is set on a components of the glasspane (vy invalidate & co) ?

alexfromsun
Offline
Joined: 2005-09-05

Hello Andre

When you move a component on a layer's glassPane
you should manually call setDirty(true) in a special case:

when you use an AbstractBufferedUI or its subclass (like LockedLayerUI)
and its isIncrementalUpdate() method returns false,
just like LockedLayerUI does in the locked state

When it is locked, the view component is invisible
and the buffered image is drawn instead

setDirty(true) means "repaint the buffer"
and I prefer to call it manually,
because in this case you have more control on the painting process

Thanks
alexp

divxdede
Offline
Joined: 2007-09-01

I understand,

So, with this things in mind, i was able to achieve my design and all works fine.

Thanks very much for your help.

PS: at this step, i'm afraid to fire tons of repaint events whithout knowing how verify this point...

alexfromsun
Offline
Joined: 2005-09-05

Hello Andre

You are welcome

> at this step, i'm afraid to fire tons of repaint events whithout knowing how verify this point...

look at the layer's source and explore how it works
:-)

Anyway calling setDirty(true) is inevitable in case you need to refresh the buffer
of an AbstractBufferedLayerUI when incrementatlUpdate flag is switched off
(it is like LockableUI behave in the locked state)

alexp

divxdede
Offline
Joined: 2007-09-01

Hello,

Just for let a feedback of my JXLayer's integration.
You can find here my (very little) project http://code.google.com/p/jbusycomponent/

And you can found a java web start demo here : http://www.jprintcover.com/jbusycomponent/jnlp/launch.php

Thanks for you help,
I have a last question, your API is under BSD licence, can i use it into a LGPL licence ? (i think yes, but i'm not completely sure)

Best regards,
André Sébastien.

alexfromsun
Offline
Joined: 2005-09-05

Hello André

Thank you for the links
the web start demo looks great!

You can certainly use JXLayer together with any code
as long as you respect the terms of the BSD license
you can read them in any JXLayer source file

Thanks
alexp