Skip to main content

Code works with JXLayer-3.0 but not 4.0

No replies
arwelbath
Offline
Joined: 2008-06-17
Points: 0

Hi,

I have been using JXlayer in a project for a while now. It's not pure Java, but is a swing GUI sitting on top of a Matlab program, but much of the GUI is in Java. (I should point out at the start I'm a Matlab programmer really, and my Java knowledge is quite limited.)

When the code runs with JXLayer-3.0, it works fine. However, if I try it with-4.0, it stops with the following error (produced by Matlab....)

Java exception occurred:
java.lang.NoSuchMethodError: org.jdesktop.jxlayer.JXLayer.<init>(Ljavax/swing/JComponent;Lorg/jdesktop/jxlayer/plaf/LayerUI;)V

This seems to be thrown somewhere the bit of Java code given below, which is a Netbeans generated form. I can't really tell what part throws the error I'm afraid, as reporting of Java errors from Matlab is not very detailed, but it is in the contstructor somewhere. I would be very greatful if someone could tell me why this works on 3.0, but not on 4.0, and how I can fix it.

(I should point out that the reason I *have* to use 4.0 is that Matlab now ships with it as part of the current release - R2011b. All Matlab figures and windows are Java based, but previous releases didn't use JXLayer, so I could just load in the jar myself and use it. However, it seems that mathworks have now decided to use it, and the 4.0 jar loads at startup and can't be removed, so if I want my code to run on the latest Matlab I need to get it to work)

Cheers,
Arwel

/*
* mainParamsGuiFrame.java
*
* Created on 28 April 2008, 09:53
*/

import java.awt.Container;
import javax.swing.JComponent;
import org.jdesktop.jxlayer.JXLayer;
import org.jdesktop.jxlayer.plaf.ext.LockableUI;
import org.jdesktop.jxlayer.plaf.effect.BufferedImageOpEffect;
import com.jhlabs.image.BlurFilter;
import java.io.Serializable;

/**
*
* @author avh45
*/
public class mainParamsGuiFrame extends javax.swing.JInternalFrame implements Serializable {

private JXLayer<JComponent> layer;
private LockableUI blurUI = new LockableUI();

/** Creates new form mainParamsGuiFrame */
public mainParamsGuiFrame() {
initComponents();
JComponent view = (JComponent) this.getContentPane();
layer = new JXLayer<JComponent>(view, blurUI);
blurUI.setLocked(false);
layer.setUI(blurUI);
this.setContentPane((layer));
}

public javax.swing.JTabbedPane getJTabbedPane1() {
return jTabbedPane1;
}

public javax.swing.JLabel getGeometryBox() {
return geometryBox;
}

public javax.swing.JLabel getProjectNameBox() {
return projectNameBox;
}

public javax.swing.JLabel getTypeBox() {
return typeBox;
}

public void setLocked() {
blurUI.setLocked(true);
repaint();
}

public void setUnlocked() {
blurUI.setLocked(false);
repaint();
}

public LockableUI getLockingPane() {
return blurUI;
}

/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
projectNameBox = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
typeBox = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
geometryBox = new javax.swing.JLabel();

setMaximizable(true);
setResizable(true);

jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jLabel1.setText("Project Name :");

projectNameBox.setBackground(new java.awt.Color(255, 255, 255));
projectNameBox.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
projectNameBox.setText(" ");
projectNameBox.setBorder(javax.swing.BorderFactory.createEtchedBorder());

jLabel3.setText(" Type :");

typeBox.setBackground(new java.awt.Color(255, 255, 255));
typeBox.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
typeBox.setText(" ");
typeBox.setBorder(javax.swing.BorderFactory.createEtchedBorder());

jLabel5.setText(" Geometry :");

geometryBox.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
geometryBox.setText(" ");
geometryBox.setBorder(javax.swing.BorderFactory.createEtchedBorder());

org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
.add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jLabel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 74, Short.MAX_VALUE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel1Layout.createSequentialGroup()
.add(typeBox, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 221, Short.MAX_VALUE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jLabel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(geometryBox, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 277, Short.MAX_VALUE))
.add(projectNameBox, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 585, Short.MAX_VALUE))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel1)
.add(projectNameBox))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel3)
.add(typeBox)
.add(jLabel5)
.add(geometryBox))
.addContainerGap(15, Short.MAX_VALUE))
);

org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(10, 10, 10)
.add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(10, 10, 10))
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 689, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 434, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>

// Variables declaration - do not modify
private javax.swing.JLabel geometryBox;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel5;
private javax.swing.JPanel jPanel1;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JLabel projectNameBox;
private javax.swing.JLabel typeBox;
// End of variables declaration

}