IntelliJ拒绝添加自定义组件 [英] IntelliJ refusing to add custom component

查看:106
本文介绍了IntelliJ拒绝添加自定义组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题如下:假设我们有以下文件:

my problem is as follows: Assume that we have the following file:

package p;
import javax.swing.*;
public class test extends JPanel {
  test(){
    super(true);
  }
}

我保存文件并进行编译。现在,在IntelliJ中,我打开一个表单并尝试向其添加 test 。它不会起作用!我点击'非调色板组件',点击我的表格,然后在打开的对话框中输入 p.test 作为我的班级名称(IntelliJ甚至在这里提供名称完成) )并检查'自动创建绑定'。点击确定后,没有任何反应。但是 - 如果我把'javax.swing.JButton'作为类名,它就可以了。这太荒谬了。我不明白我做错了什么?测试是否必须实现或覆盖某个功能?我必须修改路径吗?或者我应该将我的PC从我的窗口中拉出来?

I save the file and compile it. Now, in IntelliJ, I open a form and try to add test to it. It won't work! I click 'Non-Palette Component', click on my form and in the dialog that open up, I type p.test as my class name (IntelliJ even offers name completion here) and check 'create binding automatically'. After I click ok, nothing happens. But - if I take 'javax.swing.JButton' for the class name, it works. It's ridiculous. I don't see what I am doing wrong? Does test have to implement or override a certain function? Do I have to modify a path? Or should I just kick my PC out of my window?

推荐答案


java.lang.UnsupportedClassVersionError:测试:不支持的major.minor版本51.0

java.lang.UnsupportedClassVersionError: Test : Unsupported major.minor version 51.0

问题是您将项目语言级别设置为1.7并使用JDK 1.7构建它。 IntelliJ IDEA在您的系统上运行在JDK 1.6下,无法加载使用1.7语言级别编译的自定义组件类。

The problem is that you have the project language level set to 1.7 and using JDK 1.7 to build it. IntelliJ IDEA is running under JDK 1.6 on your system and cannot load the custom component class that was compiled with the 1.7 language level.

此问题的可能解决方案:

Possible solutions to this problem:

  • change project/module JDK to 1.6
  • in IDEA 12 it's possible to configure bytecode version per module, set it to 1.6
  • in Additional command line parameters field specify the following options: -source 1.6 -target 1.6
  • run IDEA under JDK 1.7 (applies to Windows and Linux, not recommended on Mac)

这篇关于IntelliJ拒绝添加自定义组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆