Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using Constants

 
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.).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic