I have a UI class regenerated by NetBean 5.5. the "regenerated" means I cannot simply refactor the code. Basically, the problem is one method called initComponents() has 6000 lines. so the compiler shows a "code too large" error, which is because of the 64K size limit of one method in JVM, I believe. My question is if there is a way to compile this code without defactoring it.
For Netbeans to generate a method that large you must have a ton of components added directly to a container. You could, and arguably should, refactor this by creating mid-level containers so that your top-level container doesn't have so many components directly attached. This would reduce the amount of code in your existing initComponents method and should alleviate your problem.
Joined: Oct 13, 2005
I didn't notice it was initComponents() which was so large. This is the automatically-generated method using the GUI builder in NetBeans. As Scott Escue says, you will have to divide that into smaller methods. You must have a very large display to get 6000 lines!
Joined: Apr 17, 2007
Thank you for your reply. I've tried to refactor the initComponents to smaller size sub-methods. and it works fine. however, the root cause of this problem may like what Scott said, and yes, there are tons of components added in one container. it is not easy to rewrite the whole thing.
Thank you all again for your help.
Joined: Jan 20, 2005
You should be able to refactor this in the GUI builder without too much trouble. Just add several JPanels to whatever container is giving you trouble and move some of your components onto the sub-panels. There shouldn't be any need to modify the initComponents method by hand.