Originally Posted by bbr201
If you don't need a class member variable reference, you shouldn't provide one. So you only need the class variable if you have to reference it from outside the scope where it is created. For a JButton, you would probably create it, then add a listener to it, then add it to a JPanel. You might not need to directly access it again, so you might not need a class-scope reference to it. The JPanel and the listener would have their own references to it, so it would not be garbage collected.
If it turns out that you do need to access the JButton (e.g. to change the text, or disable it), you can then move the variable declaration to class scope so it becomes accessible in other methods.
In general, try to keep variable declarations as close to their point of use as possible and don't extend their scope unnecessarily.