Netbeans代码问题:如何编辑自动生成的代码? [英] Netbeans code-gen woes: How to edit auto generated code?

查看:372
本文介绍了Netbeans代码问题:如何编辑自动生成的代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的.因此,这是一个Netbeans问题,这要归功于GUI设计器自动生成的代码. 我使用netbeans UI设计器设计了一个GUI,并针对Java 1.6进行了编译. 完成UI后,我意识到应该对Java 1.4(而不是1.6)执行此操作.为了将版本从1.6降级到1.4,我更改了表单属性以使用Swing扩展库,并且在代码中摆脱了增强的forloop和泛型,并且陷入了这个最后的错误:

Ok. So here's a netbeans issue thanks to auto generated code from GUI designer. I designed a GUI using netbeans UI designer and it was compiled for java 1.6. After I finished my UI, I realized that I was supposed to do this for Java 1.4 and not 1.6. In the effort to downgrade from 1.6 to 1.4, I altered the form properties to use Swing Extensions Library and I got rid of enhanced forloop and generics in my code and I am stuck with this final error:

类org.jdesktop.application.ResourceMap中的错误方法getString不能应用于给定类型;必需:java.lang.String,java.lang.Object []找到:java.lang.String原因:实际参数和形式参数列表的长度不同

Error method getString in class org.jdesktop.application.ResourceMap cannot be applied to given types; required: java.lang.String,java.lang.Object[] found: java.lang.String reason: actual and formal argument lists differ in length

这来自Netbeans为该方法调用自动生成的代码块:

This comes from the code block that was auto-generated by Netbeans, for this method call:

resourceMap.getString("panel.tabTitle");

很显然,这可以通过编写以下代码来解决:

Obviously, this probably could be resolved by writing this:

resourceMap.getString("panel.tabTitle",new Object{String.class});

但是,我对如何使Netbeans对其生成的代码进行更改感到困惑! 让我知道您是否曾经看过此问题并能够解决.感谢您的帮助.

I am, however, stumped on how I would make netbeans do this change to the code it generated! Let me know if you have seen this issue before and were able to resolve it. Appreciate your help.

推荐答案

如果您只想编辑代码.使用记事本之类的其他编辑器打开代码.而且,如果您在自动生成代码之前删除GEN-BEGIN:initComponents,则也可以通过netbeans编辑代码.

If you just want to edit codes. Open code with another editor just like notepad or something. And if you remove GEN-BEGIN:initComponents just before the auto generated code you can edit code through netbeans also.

这篇关于Netbeans代码问题:如何编辑自动生成的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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