*
The moose likes Beginning Java and the fly likes Using Constants Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Using Constants" Watch "Using Constants" New topic
Author

Using Constants

Landon Blake
Ranch Hand

Joined: Oct 15, 2004
Posts: 43
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

Joined: Oct 20, 2004
Posts: 280
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.).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using Constants
 
Similar Threads
type mismatch in swing is it??
MouseEvents/Listener
Can't get label to center horizontally.
Java Board Game
Centering Text Label