JComboBox防止在eclipse中打开设计页面 [英] JComboBox Warning preventing opening the design page in eclipse

查看:883
本文介绍了JComboBox防止在eclipse中打开设计页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  public static String [] blah = {Blah,Blah,Blah,Blah}; 

和一个像这样的JComboBox:

  JComboBox comboBox = new JComboBox(blah); 
comboBox.setBounds(10,56,312,37);
contentPane.add(comboBox);

组合框使用上面的字符串获取其数据,但是当我输入blah到组合框它有这个错误...

 类型安全性:构造函数JComboBox(Object [])属于原始类型JComboBox。引用通用类型JComboBox< E>应该参数化

它可以运行,因为它只是一个警告,但它是烦人的,因为它不要让我进入设计模式,除非我发表评论。设计模式给出了这个错误...

 无效资源。没有构造函数绑定。 ---新的JComboBox(locations)对于组件创建来说是无效的,它不引用现有的构造函数。 

所以我想知道是否有其他方法来克服这个问题

解决方案

问题是WindowBuilder无法处理 JComboBox< E> 首选项 - > Java下添加 jre6 来修复它。 - >安装的JRE ,并确保项目使用项目 - >属性 - > Java编译器下的执行环境'JavaSE-1.6'

所以如果你不需要java 7,你可以轻松地修复它,否则你必须等待Windowbuilder支持泛型版本。


OK i am using eclipse and its GUI editor and i have a string like this:

public static String[] blah = {"Blah", "Blah", "Blah", "Blah"};

and a JComboBox like this:

JComboBox comboBox = new JComboBox(blah);
    comboBox.setBounds(10, 56, 312, 37);
    contentPane.add(comboBox);

The combobox uses the string above to get its data but when i enter in "blah" to the combobox it has this error...

Type safety: The constructor JComboBox(Object[]) belongs to the raw type JComboBox.    References to generic type JComboBox<E> should be parameterized

it works if i run it because it is only a warning but it is annoying because it wont let me enter design mode unless i make it a comment. design mode gives this error...

INVALID SOURCE. No Constructor Binding. ---  new JComboBox(locations) is not valid source for component creation, it references not existing constructor. 

so i would like to know if there is any other way to overcome this issue

解决方案

The problem seams to be that WindowBuilder can't handle the generics version of JComboBox<E> whitch is new in jre7.

I had the same problem and fixed it by adding the jre6 under Preferences -> Java -> Installed JREs and ensuring that the project uses the execution Environment 'JavaSE-1.6' under Project -> properties -> Java Compiler.

So if you don't need java 7 you can easily fix it, else you have to wait for Windowbuilder to support the generics version.

这篇关于JComboBox防止在eclipse中打开设计页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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