PUBLIC OBJECT

SWT Frustration of the day: Constants

The SWT GridData class has 25 public static final int constants, including the following:

  • `BEGINNING`
  • `CENTER`
  • `END`
  • `HORIZONTAL_ALIGN_BEGINNING`
  • `HORIZONTAL_ALIGN_CENTER`
  • `HORIZONTAL_ALIGN_END`
  • `VERTICAL_ALIGN_BEGINNING`
  • `VERTICAL_ALIGN_CENTER`
  • `VERTICAL_ALIGN_END`

    Pop-Quiz:
    GridData also has a constructor:
    public GridData(int horizontalAlignment, int verticalAlignment, boolean grabExcessHorizontalSpace, boolean grabExcessVerticalSpace)

    Which 3 of the above constants are accepted values for the horizontalAlignment argument in this constructor?

    Pop-Solution:
    If you guessed HORIZONTAL_ALIGN_BEGINNING, HORIZONTAL_ALIGN_CENTER, and HORIZONTAL_ALIGN_END, you're wrong. The constructor only understands BEGINNING, CENTER, and END.