Time for action – using a grid

The preference values weren't lined up as expected. This is because the default preference field editor uses a FLAT style of rendering, which simply lays out the fields similar to a vertical RowLayout. Perform the following steps:

  1. Change it to a more natural look by specifying a GRID style of rendering:
    public ClockPreferencePage() {
      super(GRID);
    }
  2. Now when the preference page is displayed, it will look more natural as seen in the following screenshot:
    Time for action – using a grid

What just happened?

The default or FLAT style does not render well. It was added in 2007 (see Eclipse bug 163281) before the popularity of the grid layout increased, and typically needs to be overridden to provide a decent user interface experience. Switching to GRID does this by working out the label length, field lengths, and setting up the split accordingly. Furthermore, the view is resizable with the fields taking up the additional stretch space.

If the layout needs further customization, or the widget set needs to be extended, then it is possible to create a plain subclass of PreferencePage and create the contents in the createContents() method. Then apply any changes in the performOk() method or performApply() methods.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset