File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Using Constants" Watch "Using Constants" New topic

Using Constants

Landon Blake
Ranch Hand

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


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


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:


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:
subject: Using Constants
It's not a secret anymore!