简体   繁体   English

源1.6不支持Java Combo Box Diamond运算符

[英]Java Combo Box Diamond Operator not supported in source 1.6

Background 背景

I have developed a program which manipulates data in a database. 我开发了一个程序来处理数据库中的数据。 That however, isn't the problem I have, so I will get straight to the point. 但是,那不是我的问题,所以我将直接指出。

I made a Combo Box on the JFrame called 'Output Re-Formatted Data Files'. 我在JFrame上创建了一个名为“输出重新格式化的数据文件”的组合框。 The Combo Box should allow users to select a particular month so that the program will do a filtered search for files created in eg February 2016. 组合框应允许用户选择特定的月份,以便该程序对在2016年2月创建的文件进行过滤搜索。

The Problem 问题

The options are of course months of the year. 选项当然是一年中的几个月。 The problem I have is, the code in the initComponents() method, for that combo box is underlined in 'error red'! 我的问题是initComponents()方法中的代码,该组合框的下划线为“红色错误”!

The error says: "diamond operator is not supported in source 1.6, use source 1.7 or higher". 该错误显示:“源1.6不支持钻石运算符,请使用源1.7或更高版本”。

What I don't understand 我不明白的

I assume that source 1.6 corresponds to the JDK that you have. 我认为源1.6对应于您拥有的JDK。 So surely you only have source 1.6 if you have JDK 1.6. 因此,可以肯定的是,只有JDK 1.6才有源1.6。 But have JDK 1.8 and Netbeans 8.0.2, so how come Netbeans says I use source 1.6? 但是拥有JDK 1.8和Netbeans 8.0.2,那么Netbeans为何说我使用源代码1.6?

I'll be really thankful for anyone who explains this to me, as I've had this problem for nearly 2 months now. 我真的很感谢任何向我解释这个问题的人,因为我已经有近两个月的时间了。 I will do more of my own research in meantime too. 同时,我也会做更多自己的研究。

Init Components 初始化组件

jLabel4.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
    jLabel4.setText("Month");
    jLabel4.setToolTipText("");

    Month_ComboBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }));
    Month_ComboBox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            Month_ComboBoxActionPerformed(evt);
        }
    });

Combo Box Customised Code 组合框定制代码

I assume that source 1.6 corresponds to the JDK that you have. 我认为源1.6对应于您拥有的JDK。 So surely you only have source 1.6 if you have JDK 1.6. 因此,可以肯定的是,只有JDK 1.6才有源1.6。 But have JDK 1.8 and Netbeans 8.0.2, so how come Netbeans says I use source 1.6? 但是拥有JDK 1.8和Netbeans 8.0.2,那么Netbeans为何说我使用源代码1.6?

Well, not quite - it corresponds to which language version your source code is being compiled as . 嗯,不完全-它对应于您的源代码被编译为的语言版本。 It's very normal for later compilers to be able to compile as if you only had an earlier version of the compiler, so that if multiple people on a team have different versions, you don't get a situation where one person checks in code that another can't compile. 较晚的编译器能够只有较早版本的编译器一样进行编译非常正常的,因此,如果团队中的多个人具有不同的版本,则不会出现一个人将代码检入到另一个人的情况。无法编译。

Just change your project settings to use a source compatibility level of 1.8. 只需更改项目设置以使用1.8的源兼容性级别即可。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:(24,46)错误:-source 1.6不支持Diamond运算符(使用-source 7或更高版本来启用Diamond运算符) - Error:(24, 46) error: diamond operator is not supported in -source 1.6 (use -source 7 or higher to enable diamond operator) -source 1.5 不支持菱形运算符 - diamond operator is not supported in -source 1.5 为什么我得到错误 diamond operator is not supported in -source 1.5 in Java? - Why i get error diamond operator is not supported in -source 1.5 in Java? 错误:-source1.5不支持菱形运算符 - error: diamond operator is not supported in -source1.5 Apache Maven:-source 1.5中不支持Diamond运算符 - Apache Maven: Diamond operator is not supported in -source 1.5 NetBeans:-source 1.5不支持菱形运算符(使用-source 7或更高版本启用菱形运算符) - NetBeans : diamond operator is not supported in -source 1.5 (use -source 7 or higher to enable diamond operator) Azure DevOps Pipeline 上的错误“-source 6 中不支持菱形运算符” - Error on Azure DevOps Pipeline "diamond operator is not supported in -source 6" Visual Studio 2012 + Ant:-source 1.5中不支持Diamond运算符 - Visual Studio 2012 + Ant: diamond operator is not supported in -source 1.5 通过Maven错误进行议程代码编译:AgendaSample1Impl.java:[47,81]错误:-source 1.5中不支持Diamond运算符 - Agenda code compilation via maven error: AgendaSample1Impl.java:[47,81] error: diamond operator is not supported in -source 1.5 Cordova插件在构建时出错,在源1.6中不支持Diamond运算符,请使用源7 - Cordova plugin error on build, diamond operator isnot suported in source 1.6 use source 7
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM