I'm building a plugin for ImageJ using Swing GUI builder in Netbeans on OSX. The plugin is based on a working demo I found and altered to my needs.
Essentially when the plugin is run you see a dialog with 3 options. One to select a file (specifically a particular image file) another to open the image file using ImageJ. And a 3rd button to view the headers of the image file.
Buttons 1 & 2 work fine in both Netbeans and ImageJ and the 3rd button (Header button) works fine when I run the plugin in Netbeans.
The Header button when I run it in ImageJ throws an error:
err >Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedClassVersionError: HeaderWindow : Unsupported major.minor version 51.0
I've done some research and it seems like the error is due to mismatched versions of Java but as for as I can tell both my plugin and ImageJ are using the same versions (otherwise the plugin wouldn't run at all). Here is the code on the page that throws the error.
I've tried forcing ImageJ to use an alternate version of Java ( with no luck).
Any help would be greatly appreciated.
Here is the code for the page that throws the error:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author benwoodruff
*/
public class HeaderWindow extends javax.swing.JDialog {
static String[] annexA;
static String[] annexB;
static String[] annexC;
static String[] annexD;
/**
* Creates new form HeaderWindow
*/
public HeaderWindow(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
}
/**
* 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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jTextField1 = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jTextField1.setText("jTextField1");
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(146, 146, 146)
.add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(174, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(98, 98, 98)
.add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(176, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
public static void newScreen(String[] annexA, String[] annexB, String[] annexC, String[] annexD){
HeaderWindow.annexA = annexA;
HeaderWindow.annexB = annexB;
HeaderWindow.annexC = annexC;
HeaderWindow.annexD = annexD;
newScreen();
}
/**
* @param args the command line arguments
*/
public static void newScreen() {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(HeaderWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(HeaderWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(HeaderWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(HeaderWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
HeaderWindow dialog = new HeaderWindow(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JTextField jTextField1;
// End of variables declaration
}