Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Multi Line RadioButton and Checkbox
Multi Line RadioButton and Checkbox [message #1140130] Wed, 16 October 2013 06:37 Go to next message
Matthias Nick is currently offline Matthias NickFriend
Messages: 197
Registered: August 2013
Senior Member

I need to create a RadioButton/Checkbox, where the label of the RadioButton/Checkbox is multiline. In Swing I can do it by setting the value of the RadioButton/Checkbox in HTML tags. However, SWT doesn't support this way.

I am wondering how I can do it in SWT?

Can you help me?
Re: Multi Line RadioButton and Checkbox [message #1153216 is a reply to message #1140130] Thu, 24 October 2013 13:01 Go to previous message
Matthias Nick is currently offline Matthias NickFriend
Messages: 197
Registered: August 2013
Senior Member
Okay, I solved by creating a new custom widget. The Button is only used for the "Radio" symbol and the label is capable of displaying multiline text.
public class MultilineButton extends Composite {
  Button btn;
  Label label;

  public MultilineButton(Composite parent, int style) {
    super(parent, style);
    createContent(this, style);

  protected void createContent(Composite parent, int style) {
    this.btn = new ButtonEx(parent, style);
    this.label = new Label(parent, 0);

  protected void createLayout() {
    GridLayout containerLayout = new GridLayout(2, false);
    containerLayout.horizontalSpacing = 5; //space between button and label
    containerLayout.marginHeight = 0;
    containerLayout.marginWidth = 0;
    containerLayout.verticalSpacing = 0;

    GridData labelData = new GridData(SWT.FILL, SWT.FILL, false, false);
    labelData.verticalIndent = 3;

    GridData buttonData = new GridData(SWT.FILL, SWT.TOP, false, false);
    buttonData.verticalIndent = 3;


  public void setText(String text) {

  public void setFont( font) {

  public void setForeground( color) {

  public void setBackground( color) {

  public void removeListener(int eventType, Listener listener) {
    super.removeListener(eventType, listener);
    btn.removeListener(eventType, listener);
    label.removeListener(eventType, listener);

  public Object getLayoutData() {
    return super.getLayoutData();

  public void setSelection(boolean selected) {

  public boolean getSelection() {
    return btn.getSelection();

  public void addListener(int eventType, Listener listener) {
    super.addListener(eventType, listener);
    btn.addListener(eventType, listener);
    label.addListener(eventType, listener);

Previous Topic:Detached view freeze until resized
Next Topic:Browser.getText returning incomplete/inaccurate page string.
Goto Forum:

Current Time: Fri Nov 27 15:39:37 GMT 2015

Powered by FUDForum. Page generated in 0.03262 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software