I have been finding it difficult to create an array in netbeans because I am using the gui builder. Netbeans does not allow me to add any code to the guarded code region. I have searched online for a solution but to no avail. I created the array after initcomponent but it is throwing an illegal forward reference error because the array is defined before the gui components. My issue now is i want to make the array a class variable, i don't want to declare it as a local variable to a method. What can I do?
I don't know about your problem (sounds like your coding structure problem to me). But I will still tell you how to edit netbeans code.
First go into your project folder (Default is: C:/users/username/Documents/Netbeans Projects/ProjectName
Then go inside the src folder. And there you have your source code. All .java files are your source code (there are also .form files, but dont mess with them. Thats netbeans GUI builder data you dont want messing with).
Open the java source code with any text editor, edit and save your code, open netbeans and refresh it (right click project name and refresh). You have changed the unchangeable code.
You can add an array field after the variable declaration region. Place the caret at the closing } of the class and you can create lines below the generated region.
Related
I have this Afficheur java class in my project (its a DrawingPanel) which takes a MainWindow object in parameter. MainWindow is essentially a swing UI which Netbeans automatically generated code for as I designed it with their desing tool.
In order for it to work I have to edit this generated code by Netbeans and add 'this' in parameter to Afficheur when I create a new Afficheur (see line 85), which only is possible when I edit the code in notepad.
This method makes my code work but as soon as I try to modify the UI with the netbeans design tool the whole thing messes up. I know this is the issue because I tried removing 'this' and then modifying my UI and then adding 'this' back and everything worked fine. Its like netbeans can't generate code properly when I have modified its code. Any Idea on how I can resolve this issue?
Just go to the design tab and then right click on the item you want to change the code of and then click customize code (or something like that, i don't remember correctly) and edit the code.
I'm currently building my first GUI with IntelliJ. I arranged all my components in the GUI Designer unisng a Grid-Bag-Layout. My problem is that in the bound class, no code gets generated to make the application actually look like what I designed, there are only declarations of the different components. According to this tutorial said code should be automatically generated when compiling the project and processed to the .class file. But that doesn't seem to happen, as I only get an empty window when compiling and running my project.
Alright I figured it out. Apparently the JPanel which contains all the components doesn't get added to the JFrame by default. So I had to manually call add(panel) in my constructor.
I often have to debug old legacy code in Eclipse which I cannot or should not change. The code is often very long spaghetti code with confusing variable names.
While I debug I normally find out how things work.
I would now like to make comments on variables, methods and lines which are only disabled while I debug the code but will not change the code file itself. I could even think of changing the name of a variable from XI to countRowsProcessed just in the debugger.
Is there any plugin or maybe IDE which can do such a thing?
When Eclipse is debugging, it takes the current class file and "attaches" a source file to it, which is the source file you interact with.
I'm not sure how to do this, but you can probably make a copy of your source file, say sourceFile-wDebugComments.java and tell Eclipse to use that file for debugging purposes, rather than the original one. This way, it's not a problem to add comments, as long as you don't insert new lines in the source file.
As for renaming variables, I'm afraid vanilla Eclipse doesn't allow that.
Anyway, you might just make a copy of your whole source tree, and then modify the source file you normally can't modify. In general "can't modify" is referred to the copy on the source trunk. You can always do what you want on your local copies. If you then want to keep the thing, you can store the diff from the original file as a .diff or .patch file, and re-apply it every time you need it.
I've come across quite an odd problem with eclipse.
I was working on a project and I right clicked on a method call declared in another class and used Eclipse's handy find declaration in project (saves me quite a bit of scrolling) to run a search for that specific method declaration. Right as it should my search pane pops up with a link to the method declaration. So I click the link, the other file the method is declared in is opened automatically, and poof the Java file I had searched from disappears from my editor tabs.
So I say to myself, "damn this old version of eclipse (Indigo) has some bugs...now I've got to go reopen my file and get back to my spot...GREAT!". But when I open the file, it is treated like a plain text file. All the text is the same color, and the outline won't work!!!
So I solved the problem whilst I was typing the above up and decided to post the answer since it isn't a nice clean solution..and I doubt one exists.
Okay so file wasn't being recognized by eclipse..
So I open the file and do a Save As, and save it under another name in the same package.
Then, I went to my test code and right clicked on a method call that was declared in the file that eclipse had buggered up, and went to search for declaration in project.
Sure enough two results popped up, one in the newly saved as file, and one in the old one.
I clicked on the old one, and still plain text...no difference.
But then I clicked on the new one, and my highlighting was back!
So then I just deleted the old file and refactored.
I think somehow eclipse made the file disappear without properly closing it...just my guess, glad I resolved this nice and quickly, hopefully anyone who has the same issue can be helped by this.
This happened to me a couple of minutes ago. Trying to close/open the projet, restarting eclipse did not work for me.
The steps I used were:
Pick another Java file (same package) right next to the bogus one (make sure syntax highlighting works on this one)
Choose 'Save As' and override the bogus one.
Verify that the bogus one now has proper syntax highlighting
Use git checkout -- to retrieve you original file
Et voilĂ !
As I'm typing the code, does eclipse look up instantly in the class file in order to retrieve the class members for the intellisense or is there a file seperately created that eclipse refers to?
I think you are asking about how Eclipse JDT content assist works. When you press ., a content assist invocation occurs. This triggers a reconcile operation in JDT. A reconcile is kind of like a mini-compile. The current file is parsed and resolved, but no byte code is created (that's what a reconcile is). The results of the reconcile are what is used to populate content assist.
This is only scratching the surface of what is going on. In actuality, things are quite complex with caches, diet parses, and bindings used and created as needed.