Skip to main content

Problem using Piet Block's JXLayer Transform Demo

4 replies [Last post]
davidcw
Offline
Joined: 2009-09-14
Points: 0

Hello,

I just discovered JXLayer yesterday, but am running into problems using Piet Block's JXLayer Transform (http://www.pbjar.org/blogs/jxlayer/jxlayer40/). I have already e-mailed Piet, but he doesn't seem to be having the same problem. So, I was hoping someone here could reveal what I'm overlooking.

The specific error I'm getting is:

Java 1.6.0_16 14.2-b01: RepaintManager delegate facility for JavaFX will be used.
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: org.jdesktop.jxlayer.JXLayer.getGlassPane()Ljavax/swing/JComponent;
at org.pbjar.jxlayer.plaf.ext.transform.TransformLayout.layoutContainer(
TransformLayout.java:106)

I have already tried to solve the problem via several different approaches. All of the following tests were done with "Java 1.6.0_16" 32bit Standard Edition JDK and JRE. Not that it should matter, but I tried on Windows XP and Vista.

My specific setup involved running a very simple, one-file application, whose code is included below.

The setups I have used to try and run this "Application.java" file are:
- "jxlayer.jar" from the project homepage, downloaded and extracted from "https://jxlayer.dev.java.net/bin/jxlayer-all.zip".
- "PBTransform.jar" from "http://www.pbjar.org/blogs/jxlayer/jxlayer40/".
- I have also tried including and not including "filters.jar" and "swingx.jar".
- I have tried running it in two ways: in Eclipse, and compiled/run via command line, each time ensuring all the jar files were on the classpath.

======== Application.java =======

public class Application {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Application application = new Application();
application.createAndShowGUI();
}
});
}

public void createAndShowGUI() {
JFrame frame = new JFrame();
JPanel panel = new JPanel();
JXLayer layer = TransformUtils.createTransformJXLayer(panel, 2, new QualityHints());
//JXLayer layer = new JXLayer(panel,new LockableUI()); // Creating the layer this way works.
Container contentPane = frame.getContentPane();
contentPane.add(layer);
frame.setVisible(true);
}
}

===========================

I'd be happy to post more information... just let me know what you need.

- Thank you!
- David Wang

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
davidcw
Offline
Joined: 2009-09-14
Points: 0

I found a working solution to my problem, so I thought I would post it. But, I'm still curious why some other things I tried didn't work.

My Solution (using Eclipse, and Sun's JDK 1.6 u 16 SE):
1. Create a Java project from Piet's Transformation Demo source code (http://www.pbjar.org/blogs/jxlayer/jxlayer40/Transform_src.zip).
2. Add "jxlayer.jar" (from https://jxlayer.dev.java.net/bin/jxlayer-all.zip) and "swingx-1.0.jar" (from https://swingx.dev.java.net/) to the classpath of that project.
3. Create another Java project with my "Application.java" source code. Reference/depend-on the Transformation Demo project (step 1) and add "jxlayer.jar" to the classpath.
4. IMPORTANT: In Eclipse, Window->Preferences -> Java->Compiler->Errors/Warnings. under "Deprecated and restricted API", I set "Forbidden reference" to Warning (instead of Error). This allows the successful compilation of files depending on "SwingUtilities3".

My remaining question (which is more general-Java that JXLayer related) is:
Why was it necessary for me to rebuild Piet's Transformation Demo? Even with the "Forbidden Reference" errors disabled. It seems to me, a project with "Application.java", and the classpath files "jxlayer.jar", "swingx-1.0.jar", and "PBTransform.jar" should work. Instead I still get the error "...NoSuchMethodError:....getGlassPane()".

- If anyone can figure this last question out...
- Thanks!

pietblok
Offline
Joined: 2003-07-17
Points: 0

Hi David,

Finally i succeeded to get the same exception as you did by creating a separate project for your sample code (in Eclipse) and referring to jxlayer.jar and PBTransform.jar. I have no idea whatever causes this problem.

I rebuild the transform project and the problem is gone! The demo site has been adjusted to the newly build jar. Please download the PBTransform.jar file and try again.

Piet

ridwaanb
Offline
Joined: 2011-01-24
Points: 0

Hi Piet,
Thanks for your great demo.
I am new to JXLayer, and i have been trying to implement a zoom functionality on a JPanel for ex. I checked your source code, but however i find it a bit complex to follow.
Lets say, we have this simple frame example below with a panel on it. I want to zoom on that panel. Can you please explain the steps to be executed and what re-usable elements from your demo can we used?
###Frame example ###
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch(Exception e) {
System.out.println("Error setting native LAF: " + e);
}

JFrame frame = new JFrame("Frame in Java Swing");
frame.setSize(400, 400);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JPanel jPanel = new JPanel();
jPanel.setBackground(Color.RED);

frame.getContentPane().setLayout(new FlowLayout());

JXLayer layer = TransformUtils.createTransformJXLayer(jPanel, 2, new QualityHints());
frame.getContentPane().add(layer);
frame.setVisible(true);
}
###

davidcw
Offline
Joined: 2009-09-14
Points: 0

Fantastic! I just downloaded your new version of "PBTransform.jar"... and it works.

That was a bizarre problem. Thanks for fixing it. And, if I haven't said it yet, thanks for creating that transform demo.

- David