插件在NetBeans IDE中运行完美,但在ImageJ

时间:2015-09-21 14:46:39

标签: java macos swing netbeans imagej

我正在使用OSX上的Netbeans中的Swing GUI构建器为ImageJ构建一个插件。该插件基于我发现并根据我的需求改变的工作演示。

基本上,当插件运行时,您会看到一个包含3个选项的对话框。一个用于选择另一个文件(特别是特定图像文件)另一个用ImageJ打开图像文件。还有第3个按钮可以查看图像文件的标题。

按钮1& Netbeans和ImageJ中的2个工作正常,当我在Netbeans中运行插件时,第3个按钮(Header按钮)工作正常。

在ImageJ中运行Header按钮时会抛出错误:

  

错误>线程“AWT-EventQueue-0”中的异常java.lang.UnsupportedClassVersionError:HeaderWindow:不支持的major.minor版本51.0

我做了一些研究,似乎错误是由于Java版本不匹配,但至于我可以告诉我的插件和ImageJ都使用相同的版本(否则插件根本不会运行) 。以下是引发错误的页面上的代码。

我试图强迫ImageJ使用Java的替代版本(没有运气)。

非常感谢任何帮助。

以下是抛出错误的页面的代码:

      /*
 * 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                   
}

0 个答案:

没有答案