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 250740

Summary: Introduce Field on local variable is unintuitive
Product: java Reporter: swpalmer <swpalmer>
Component: HintsAssignee: Svata Dedic <sdedic>
Status: NEW ---    
Severity: normal    
Priority: P2    
Version: 8.0.2   
Hardware: PC   
OS: Windows 7   
Issue Type: ENHANCEMENT Exception Reporter:

Description swpalmer 2015-02-26 15:40:12 UTC
Select a local variable where it is declared:

e.g.

Button button = new Button(); // <-- select 'button'

Go to the Refactor menu and select Introduce->Field...

A dialog appears stating "Invalid Selection".  This is counter intuitive and should be corrected.  The obvious expectation of the user is that they wish to make the local variable a field variable.
Comment 1 swpalmer 2015-02-26 15:47:08 UTC
I also can't find any mention of the 'Introduce Field' refactoring in the documentation. Searching the help for "refactor introduce field" produces many results, none of which appear to have anything to do with this refactoring.  I simply don't know how to use this refactoring because it doesn't do what I expect and I can't find out how it is supposed to be used.
Comment 2 swpalmer 2015-02-26 15:55:31 UTC
After reading this
http://docs.oracle.com/cd/E50453_01/doc.80/e50452/build_japps.htm#NBDAG592

I tried selecting the entire statement and it worked.  I don't think that is very intuitive, as it is only the variable that is relevant, not the initialization.