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.
- Open the
Hello
class and go to thecreate
method that creates the part's UI. - 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!");
- 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.