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.

Bug 131975

Summary: "Implement all abstract methods" hint generates a duplicate of the code in initComponent
Product: java Reporter: devon_c_miller <devon_c_miller>
Component: EditorAssignee: Jan Lahoda <jlahoda>
Status: RESOLVED WONTFIX    
Severity: blocker    
Priority: P3    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:

Description devon_c_miller 2008-04-03 19:09:10 UTC
This is very simple and very reproducible:

Create a new Panel form
Switch to Source view
Go to the bottom of the file.
Between the end of the variables declaration guard block and the closing curly brace insert the following:

    class ClearAction extends Abstract Action

The line will be marked as an error (red squiggly underline) and the lightbulb badge appears in the left margin.
Click the lightbulb and it presents 2 choices ("Add import..." or "Create class...").
Click "Add import".
The line "import javax.swing.AbstractAction;" is added to the file.
Click the light bulb again to get 1 choice: "Implement all abstract methods"
Click that

I would expect to see:
    {
        public void actionPerformed(ActionEvent e)
        {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    }

But instead I got:

        public void actionPerformed(ActionEvent e)
        {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>
    
    
    // Variables declaration - do not modify
    // End of variables declaration
    class ClearAction extends AbstractAction

It looks like it grabbed everything from the opening brace of initComponents to the closing brace of the outer class,
then pasted it in after the original "class ClearAction extends AbstractAction" and the implementation of "actionPerformed".

I realize this is occurring because I never entered the open/close braces for the inner class. Trying again with either
the opening and closing brace, prevents this bug.

The code completion should have either:
a) first added the missing braces to the class decl, or
b) refused to do anything at all.
Comment 1 Jan Becicka 2008-11-13 09:25:02 UTC
Will resolve later.
Comment 2 Quality Engineering 2009-11-02 10:57:06 UTC
NetBeans.org Migration: changing resolution from LATER to WONTFIX