This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Using Constants  RSS feed

 
Landon Blake
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm looking for some help with the use of constants. For example, in the following statement we are setting the horizontal text position of a JLabel object to CENTER.

testLabel.setHorizontalTextPosition(JLabel.CENTER);

Is "JLabel.CENTER" a method call, or simply a way to reference the CENTER constant of the JLabel class?

Thanks,

Landon
 
Amit Saini
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it was a method call then it would have parenthesis (). But I dont see that , so CENTER is a constant. JLabel inherits this constant from the javax.swing.SwingConstants class.

API notes:

CENTER

public static final int CENTER

The central position in an area. Used for both compass-direction constants (NORTH, etc.) and box-orientation constants (TOP, etc.).
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!