This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Netbeans 6.0 Beta 1 attempts to add a method inside another one: While building a GUI sometimes adding a method to a button will place the auto-generated inside another method generating several error and corrupting the file.
Created attachment 49331 [details] The gray lines indicating the auto-generated code are wrong
Could you describe step by step how to reproduce it? thanks
I haven't been able to reproduce it. But I found a way to fix it =) Opening the class in a text editor and placing the: //GEN-LAST:event_racionalesEjericiosBotonActionPerformed In the correct bracket ( } ) fixed the problem....sort of...now the method has no gray lines but the IDE will insert new methods right after the last one with correct "gray lines" BEFORE: private void racionalesEjericiosBotonActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_racionalesEjericiosBotonActionPerformed try { String aux = controlRacional.parseadorDeRacionales(this.racionalesEjericiosOperacionesText.getText()).toString(); this.racionalesEjerciciosArea.setText(aux);//GEN-LAST:event_ racionalesEjericiosBotonActionPerformed } catch (ErrorEnCadenaException ex) { Logger.getLogger(Interfaz.class.getName()).log(Level.SEVERE, null, ex); } } AFTER: private void racionalesEjericiosBotonActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_racionalesEjericiosBotonActionPerformed try { String aux = controlRacional.parseadorDeRacionales(this.racionalesEjericiosOperacionesText.getText()).toString(); this.racionalesEjerciciosArea.setText(aux); } catch (ErrorEnCadenaException ex) { Logger.getLogger(Interfaz.class.getName()).log(Level.SEVERE, null, ex); } }//GEN-LAST:event_ racionalesEjericiosBotonActionPerformed
Created attachment 49377 [details] The code after moving the "//GEN-LAST.." via a text editor
Yes, it is clear what is wrong - and the way you fixed it is correct. Do you remember which method (even handler) you've added when the problem happened? Did anything like this happen more than once to you?
At first i thought it had something to do with using the tips (the little light bulb) to auto-wrap an instruction in a try-catch block and the IDE wont count these extra lines into de mix....but i haven't been able to do it again....I'll post again if I find out whats wrong.
It was an ActionPerformed event for a JButton...
Actually it makes more sense this was was caused by using the "Surround with try-catch" feature. It might somehow mis- place the ending guarded block comment. I can't imagine how adding another event handler could cause this - it just creates a new guarded section, does not change existing ones. Reassigning to java/source guys if they have some idea. But we'd definitely welcoem the exact steps to reproduce the problem.
Im posting this here and not as a separate problem because i think its related, after selecting a few lines of code and using the "Reformat code" some of my code will disappear for no reason. See the before and after picture, notice the "collapsable" guides on the left are totally wrong on the before picture. This is on the same file where I've been having problems. I think something is seriously wrong =(
Created attachment 49508 [details] before, reformatting code (notice the wrong guidelines)
Created attachment 49509 [details] after the reformat
The second problem (desc10,11,12) is not related to the first one so I've filed it as separate issue 116807. But I cannot see what is wrong on the "before" picture.
*** Issue 121178 has been marked as a duplicate of this issue. ***
*** Issue 121329 has been marked as a duplicate of this issue. ***
*** Issue 121281 has been marked as a duplicate of this issue. ***
Hi, I also encountered the same problem. The IDE will insert a function in another function. Here is the code displayed with an external editor: the //GEN-LAST:event_gradientViewer1MouseDragged is not at the good place. I cannot reproduce the problem, but I can say that I've played with comments of code (/* ... */) before the bug occurs. I also added a @SuppressWarnings("static-access") with the automatic corrector. Product Version: NetBeans IDE 6.0 (Build 200711261600) Java: 1.6.0; Java HotSpot(TM) Client VM 1.6.0-b105 System: Linux version 2.6.20-16-generic running on i386; UTF-8; fr_FR (nb) @SuppressWarnings("static-access") private void gradientViewer1MouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_gradientViewer1MouseDragged // TODO add your handling code here: JLabel labelXY=null;//GEN-LAST:event_gradientViewer1MouseDragged int button = evt.getButton(); Point p = evt.getPoint(); p.x = p.x - gradientViewer1.getWidth()/2; // pour mettre l'origine au centre p.y = p.y - gradientViewer1.getHeight()/2;// pour mettre l'origine au centre String s = String.valueOf("x="+p.x)+" y="+String.valueOf(p.y); jLabel3.setText(s); //if (button==evt.BUTTON1){ if (SwingUtilities.isLeftMouseButton(evt)){ labelXY=jLabelPoint1; changeGradient(p, gradientViewer1.getGradient().getColor1(), gradientViewer1.getGradient().getPoint2(), gradientViewer1.getGradient().getColor2(),false); } //else if (button==evt.BUTTON3){ else if (SwingUtilities.isRightMouseButton(evt)){ labelXY=jLabelPoint2; changeGradient(gradientViewer1.getGradient().getPoint1(), gradientViewer1.getGradient().getColor1(), p, gradientViewer1.getGradient().getColor2(),false); } if (labelXY!=null){ //String s; s = " x = " + String.valueOf(p.getX()); s += " y = " + String.valueOf(p.getY()); labelXY.setText(s); } }
code generator issue
*** Issue 126878 has been marked as a duplicate of this issue. ***
Actually, it turns out that the root cause is not in the codegen. The problem can be reproduced manually. The steps to reproduce are: 1. Start the IDE, create a new J2SE project 2. Create a new JPanel form 3. Drag and drop JButton into the form, right click the added button, choose Events/Action/actionPerformed - the generated handler will be opened in the editor. 4a. either: replace the autogenerated comment with "new FileOutputStream("").write(0);", resolve imports, and choose Surround block with try-catch 4b. or: place caret at the very first offset at the last line of the handler method (the line is guarded) and press "enter". 5. save and close the file and reopen it - the guarded block ends at wrong place The problem seems to be caused by Positions inconsistency in the InteriorSectionImpl - after step 4a or 4b, the "body" positions bound is not immediately followed by the "footer" positions bound. And the (wrong) "body" positions are then used to generate the "guard" comments when the file is being saved.
*** Issue 128267 has been marked as a duplicate of this issue. ***
*** Issue 128567 has been marked as a duplicate of this issue. ***
*** Issue 130333 has been marked as a duplicate of this issue. ***
*** Issue 131562 has been marked as a duplicate of this issue. ***
moving opened issues from TM <= 6.1 to TM=Dev
*** Issue 137638 has been marked as a duplicate of this issue. ***
I had the same problem, but my pattern doesn't fit in jlahoda steps. (------- Additional comments from jlahoda Thu Feb 14 16:07:13 +0000 2008 -------). I had no buttons in my forms. I just played with menu items and a lot of try catch. Unfortunately I cannot reproduce it, by I could correct it fallowing the posts.
In fact, lordthecrow's use-case matches exactly this issue. This problem, of course, is not button specific. The key ingredients seem to be the generation of an event handler for some event of some component and invocation of Surround with try-catch.
I think the priority of this issue is not appropriate and should be increased. It is simply reproducible and consequences are very bad. The number of duplicates is raising as well. Therefore I set priority as P2
janie: Is it really simply reproducible? Could you share your test case please? In duplicates you can read that it happened but I cannot find steps how to reproduce. Even jlahoda has not been able to reproduce it again.
I can reproduce it as well, following Honza's steps to reproduce (desc21) Product Version: NetBeans IDE Dev (Build 20080618044251) Java: 1.6.0_10-beta; Java HotSpot(TM) Client VM 11.0-b12 System: Linux version 2.6.22-14-generic running on i386; UTF-8; en_US (nb)
I followed the steps described by jlahoda and it's reproducible as well (windows XP, trunk Build 20080619).
It looks that the java source generator removes end part of the body of the interior guarded section while generating try/catch block. I will fix guarded section's positions to survive such a manipulation.
*** Issue 122714 has been marked as a duplicate of this issue. ***
fixed as http://hg.netbeans.org/main/rev/0ee22aad73ba
*** Issue 138384 has been marked as a duplicate of this issue. ***
Integrated into 'main-golden', available in NB_Trunk_Production #285 build Changeset: http://hg.netbeans.org/main/rev/0ee22aad73ba User: Jan Pokorsky <jpokorsky@netbeans.org> Log: #116456: introduced BiasedPosition to guarantee the position survives insert/remove operations properly
*** Issue 140360 has been marked as a duplicate of this issue. ***
*** Issue 143325 has been marked as a duplicate of this issue. ***
*** Issue 143539 has been marked as a duplicate of this issue. ***
*** Issue 147115 has been marked as a duplicate of this issue. ***
*** Issue 147437 has been marked as a duplicate of this issue. ***