In addition to what was said by Marko Topolnik, there is the fact that if the JLabel
was to have a static member by the same name in the future, the mere recompilation of the JLabel.java
would not make the calling code aware of the constant existing in that module. Instead until recompilation of the code, it would still happily use the Component.CENTER_ALIGNMENT
despite the source code stating contrarily.
The latter reference is sure to refer to the static member of Component
by the name CENTER_ALIGNMENT
, whereas the former would refer to the member in either Component
or in any subclass up to JLabel
if the name is redefined in any of them later on.
In case of using a static function or member variable, if a later version of the subclass also declares an overridden one, the meaning of the indirect access would change even without recompilation. All of this might be a bit hypothetical, but good to consider anyway.