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 - Introduce Field on local variable is unintuitive
Summary: Introduce Field on local variable is unintuitive
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.0.2
Hardware: PC Windows 7
: P2 normal (vote)
Assignee: Svata Dedic
Depends on:
Reported: 2015-02-26 15:40 UTC by swpalmer
Modified: 2015-04-07 12:41 UTC (History)
0 users

See Also:
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description swpalmer 2015-02-26 15:40:12 UTC
Select a local variable where it is declared:


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

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.