Skip to main content

Problem with locking UI

7 replies [Last post]
steff4711
Offline
Joined: 2008-07-02
Points: 0

Hello there,

everytime i use the locking mechanism like that:

lockableUI.setLocked(true);

it seems that the JPanel i passed to the JXLayer for that UI is beeing blanked. Although i did something link that before:

jxLayer.setOpaque(true);

but in some cases it i need a

lockableUI.setLocked(false);

to have it opaque again?!??!?!?!?

Any ideas?

thx

steff

Message was edited by: steff4711

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
Points: 0

Hello Steff

It sounds strange, because setOpaque() and setLocked() are not supposed to be connected,

could you post a code snippet which illustrate the problem?

Thanks

alexp

hokr
Offline
Joined: 2008-07-14
Points: 0

Hello Alex,

I possibliy just had the same problem as Steff4711. He describes his problem with:

[i]"it seems that the JPanel i passed to the JXLayer for that UI is beeing blanked."[/i]

I tried out using LockableUI the first time. As effect when locking the container (a JPanel) all components inside where simply no longer visible - so the window looked [i]"blanked"[/i]. But there were no "LockedEffects" to see.

Exploring and debugging the sources from LockableUI I located the problem in the setLocked() method, line 190 ff:

// setDirty() will be called from the layer's focusListener
// when focus already left layer's view and hiding it
// in the paintLayer() won't mess the focus up
getLayer().requestFocusInWindow();

But the layer didn't get the focus. So I tried a small change:

if (!getLayer().requestFocusInWindow() || !getLayer().hasFocus()) setDirty( true );

This way it worked.

As I'm relativly new using AWT/Swing all I wrote above may be foolish and a result of misunderstandings. If so - sorry for that. I just hope to help solving a problem.

best regards
Holger

alexfromsun
Offline
Joined: 2005-09-05
Points: 0

Hello Holger

I need a runnable test case which reproduces the problem,
I've just written a small test which works fine for me,
please help me to reproduce that "blank panel" effect

[code]
import org.jdesktop.jxlayer.JXLayer;
import org.jdesktop.jxlayer.plaf.ext.LockableUI;
import org.jdesktop.jxlayer.plaf.effect.BufferedImageOpEffect;
import javax.swing.*;
import com.jhlabs.image.BlurFilter;

public class LockTest {

private static void createGui() {

final JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
panel.add(new JButton("JButton"));

JXLayer l = new JXLayer(panel);
LockableUI ui = new LockableUI();
ui.setLockedEffects(new BufferedImageOpEffect(new BlurFilter()));

l.setUI(ui);
ui.setLocked(true);

frame.add(l);
frame.setSize(200, 200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}

public static void main(String[] args) throws Exception {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
LockTest.createGui();
}
});
}
}
[/code]

Thanks
alexp

hokr
Offline
Joined: 2008-07-14
Points: 0

Hello Alex,



your small test works as it should. But it is easy to modify it to reproduce the effect: The LockableUI must not be locked at the beginning.



I changed the code so that the button is used to call ui.setLocked(). The other setLocked()-call is set in comments. Pressing the button then produces a blank screen. The button is no longer visible. Tested in a 1.5 and a 1.6 JRE.



[code]
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import org.jdesktop.jxlayer.JXLayer;
import org.jdesktop.jxlayer.plaf.ext.LockableUI;
import org.jdesktop.jxlayer.plaf.effect.BufferedImageOpEffect;
import javax.swing.*;
import com.jhlabs.image.BlurFilter;

public class LockTest {

private static void createGui() {

final JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
final LockableUI ui = new LockableUI();
JButton button = new JButton("JButton");
button.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
ui.setLocked( true );
}
} );
panel.add(button);

JXLayer l = new JXLayer(panel);
ui.setLockedEffects(new BufferedImageOpEffect(new BlurFilter()));

l.setUI(ui);
// ui.setLocked(true);

frame.add(l);
frame.setSize(200, 200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}

public static void main(String[] args) throws Exception {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
LockTest.createGui();
}
});
}
}
[/code]


regards

Holger

alexfromsun
Offline
Joined: 2005-09-05
Points: 0

Hello Holger

Thanks a lot for your help!

I've just fixed this problem,
please download the new jxlayer.jar and let me know if it works for you

alexp

hokr
Offline
Joined: 2008-07-14
Points: 0

Hello Alex,

everything looks fine in my application with the new version. No "blanked" screen. The LockedEffects are visualized as expected.

Thank you very much
Holger

alexfromsun
Offline
Joined: 2005-09-05
Points: 0

It's my pleasure Holger

let me know if have any other comment or suggestions

alexp