Time for action – using custom CSS classes

Very often when building a user interface, there will be a need to repeat styles across different components in the application. Instead of using the generic class type, or having to encode multiple styles on a part-by-part basis, CSS classes can be used to define a standard style and applied to individual widgets.

A label will be added to the sample part and associated with a CSS style, and that will be stored in the default CSS file.

  1. Open the Hello class and go to the create method that creates the part's UI.
  2. At the end of the method, add a new Label, which will be used to demonstrate the styling:
    Label label = new Label(parent, SWT.NONE);
    label.setText("Danger Will Robinson!");
  3. Associate the label with ...

Get Eclipse Plug-in Development Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.