Example usage for org.eclipse.swt.widgets Label setLayoutData

List of usage examples for org.eclipse.swt.widgets Label setLayoutData

Introduction

In this page you can find the example usage for org.eclipse.swt.widgets Label setLayoutData.

Prototype

public void setLayoutData(Object layoutData) 

Source Link

Document

Sets the layout data associated with the receiver to the argument.

Usage

From source file:FormLayoutExample.java

FormLayoutExample() {
    d = new Display();
    s = new Shell(d);
    s.setSize(250, 250);/*from   w ww .j ava2 s. c  o m*/

    s.setText("A FormLayout Example");
    s.setLayout(new FormLayout());

    final Label l1 = new Label(s, SWT.RIGHT);
    l1.setText("First Name");
    FormData fd = new FormData();
    fd.top = new FormAttachment(10, 10);
    fd.left = new FormAttachment(0, 10);
    fd.bottom = new FormAttachment(30, 0);
    fd.right = new FormAttachment(40, 0);
    l1.setLayoutData(fd);

    final Label l2 = new Label(s, SWT.RIGHT);
    l2.setText("Last Name");
    fd = new FormData();
    fd.top = new FormAttachment(l1, 5);
    fd.left = new FormAttachment(0, 10);
    fd.bottom = new FormAttachment(40, 0);
    fd.right = new FormAttachment(40, 0);
    l2.setLayoutData(fd);

    final Text t1 = new Text(s, SWT.BORDER | SWT.SINGLE);
    fd = new FormData();
    fd.top = new FormAttachment(l1, 0, SWT.TOP);
    fd.left = new FormAttachment(l1, 10);
    t1.setLayoutData(fd);

    final Text t2 = new Text(s, SWT.BORDER | SWT.SINGLE);
    fd = new FormData();
    fd.top = new FormAttachment(l2, 0, SWT.TOP);
    fd.left = new FormAttachment(l2, 10);
    t2.setLayoutData(fd);

    s.open();
    while (!s.isDisposed()) {
        if (!d.readAndDispatch())
            d.sleep();
    }
    d.dispose();
}

From source file:MainClass.java

public void createContents(Shell shell, String location) {
    shell.setLayout(new FormLayout());

    Composite controls = new Composite(shell, SWT.NONE);
    FormData data = new FormData();
    data.top = new FormAttachment(0, 0);
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    controls.setLayoutData(data);/* ww w  .  ja v a  2  s .  c o m*/

    Label status = new Label(shell, SWT.NONE);
    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.bottom = new FormAttachment(100, 0);
    status.setLayoutData(data);

    final Browser browser = new Browser(shell, SWT.BORDER);
    data = new FormData();
    data.top = new FormAttachment(controls);
    data.bottom = new FormAttachment(status);
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    browser.setLayoutData(data);

    controls.setLayout(new GridLayout(7, false));

    Button button = new Button(controls, SWT.PUSH);
    button.setText("Back");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.back();
        }
    });

    button = new Button(controls, SWT.PUSH);
    button.setText("Forward");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.forward();
        }
    });

    button = new Button(controls, SWT.PUSH);
    button.setText("Refresh");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.refresh();
        }
    });

    button = new Button(controls, SWT.PUSH);
    button.setText("Stop");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.stop();
        }
    });

    final Text url = new Text(controls, SWT.BORDER);
    url.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    url.setFocus();

    button = new Button(controls, SWT.PUSH);
    button.setText("Go");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.setUrl(url.getText());
        }
    });

    Label throbber = new Label(controls, SWT.NONE);
    throbber.setText(AT_REST);

    shell.setDefaultButton(button);

    browser.addCloseWindowListener(new AdvancedCloseWindowListener());
    browser.addLocationListener(new AdvancedLocationListener(url));
    browser.addProgressListener(new AdvancedProgressListener(throbber));
    browser.addStatusTextListener(new AdvancedStatusTextListener(status));

    if (location != null) {
        browser.setUrl(location);
    }
}

From source file:grafici.PazientiTimeSeriesChart.java

/**
 * A demonstration application showing how to create a simple time series
 * chart.  This example uses monthly data.
 *
 * @param title  the frame title.//from w  ww . ja va2 s.  c  o  m
 */
public PazientiTimeSeriesChart(String title, Composite parent, int style, int tipo) {
    super(parent, style);

    Label titolo = new Label(this, SWT.NONE);
    titolo.setFont(new Font(titolo.getDisplay(), "arial", 15, SWT.BOLD));
    titolo.setText(title);
    GridData gdLbl = new GridData(SWT.FILL);
    titolo.setLayoutData(gdLbl);
    Composite cmp = new Composite(this, SWT.FILL | SWT.EMBEDDED);
    GridData gdCmp = new GridData(SWT.FILL);
    gdCmp.horizontalAlignment = SWT.FILL;
    gdCmp.verticalAlignment = SWT.FILL;
    gdCmp.grabExcessHorizontalSpace = true;
    gdCmp.grabExcessVerticalSpace = true;
    cmp.setLayoutData(gdCmp);
    cmp.setLayout(new GridLayout(1, false));
    JPanel chartPanel = createDemoPanel(tipo);
    Frame graphFrame = SWT_AWT.new_Frame(cmp);
    graphFrame.add(chartPanel);
    graphFrame.pack();

    GridData gdThis = new GridData(SWT.FILL);
    gdThis.horizontalAlignment = SWT.FILL;
    gdThis.verticalAlignment = SWT.FILL;
    gdThis.grabExcessHorizontalSpace = true;
    gdThis.grabExcessVerticalSpace = true;

    this.setLayoutData(gdThis);
    this.setLayout(new GridLayout(1, false));
}

From source file:grafici.FattureTimeSeriesChart.java

/**
 * A demonstration application showing how to create a simple time series
 * chart. This example uses monthly data.
 * /*from w w  w .  ja v a 2 s . co  m*/
 * @param title
 *            the frame title.
 */
public FattureTimeSeriesChart(String title, Composite parent, int style, int tipo) {
    super(parent, style);
    System.out.println(2);
    Label titolo = new Label(this, SWT.NONE);
    titolo.setFont(new Font(titolo.getDisplay(), "arial", 15, SWT.BOLD));
    titolo.setText(title);
    GridData gdLbl = new GridData(SWT.FILL);
    titolo.setLayoutData(gdLbl);
    Composite cmp = new Composite(this, SWT.FILL | SWT.EMBEDDED);
    GridData gdCmp = new GridData(SWT.FILL);
    gdCmp.horizontalAlignment = SWT.FILL;
    gdCmp.verticalAlignment = SWT.FILL;
    gdCmp.grabExcessHorizontalSpace = true;
    gdCmp.grabExcessVerticalSpace = true;
    cmp.setLayoutData(gdCmp);
    cmp.setLayout(new GridLayout(1, false));
    JPanel chartPanel = createPanel(tipo);
    Frame graphFrame = SWT_AWT.new_Frame(cmp);
    graphFrame.add(chartPanel);
    graphFrame.pack();

    GridData gdThis = new GridData(SWT.FILL);
    gdThis.horizontalAlignment = SWT.FILL;
    gdThis.verticalAlignment = SWT.FILL;
    gdThis.grabExcessHorizontalSpace = true;
    gdThis.grabExcessVerticalSpace = true;

    this.setLayoutData(gdThis);
    this.setLayout(new GridLayout(1, false));
}

From source file:grafici.MediciTimeSeriesChart.java

/**
 * A demonstration application showing how to create a simple time series
 * chart. This example uses monthly data.
 * //from  ww  w  .  j a v a  2  s . com
 * @param title
 *            the frame title.
 */
public MediciTimeSeriesChart(String title, Composite parent, int style, int tipo) {
    super(parent, style);

    Label titolo = new Label(this, SWT.NONE);
    titolo.setFont(new Font(titolo.getDisplay(), "arial", 15, SWT.BOLD));
    titolo.setText(title);
    GridData gdLbl = new GridData(SWT.FILL);
    titolo.setLayoutData(gdLbl);
    Composite cmp = new Composite(this, SWT.FILL | SWT.EMBEDDED);
    GridData gdCmp = new GridData(SWT.FILL);
    gdCmp.horizontalAlignment = SWT.FILL;
    gdCmp.verticalAlignment = SWT.FILL;
    gdCmp.grabExcessHorizontalSpace = true;
    gdCmp.grabExcessVerticalSpace = true;
    cmp.setLayoutData(gdCmp);
    cmp.setLayout(new GridLayout(1, false));
    JPanel chartPanel = createDemoPanel(tipo);
    Frame graphFrame = SWT_AWT.new_Frame(cmp);
    graphFrame.add(chartPanel);
    graphFrame.pack();

    GridData gdThis = new GridData(SWT.FILL);
    gdThis.horizontalAlignment = SWT.FILL;
    gdThis.verticalAlignment = SWT.FILL;
    gdThis.grabExcessHorizontalSpace = true;
    gdThis.grabExcessVerticalSpace = true;

    this.setLayoutData(gdThis);
    this.setLayout(new GridLayout(1, false));
}

From source file:grafici.PrenotazioneTimeSeriesChart.java

/**
 * A demonstration application showing how to create a simple time series
 * chart. This example uses monthly data.
 * //from  w  ww  .  ja va2  s  .co m
 * @param title
 *            the frame title.
 */
public PrenotazioneTimeSeriesChart(String title, Composite parent, int style, int tipo) {
    super(parent, style);

    Label titolo = new Label(this, SWT.NONE);
    titolo.setFont(new Font(titolo.getDisplay(), "arial", 15, SWT.BOLD));
    titolo.setText(title);
    GridData gdLbl = new GridData(SWT.FILL);
    titolo.setLayoutData(gdLbl);
    Composite cmp = new Composite(this, SWT.FILL | SWT.EMBEDDED);
    GridData gdCmp = new GridData(SWT.FILL);
    gdCmp.horizontalAlignment = SWT.FILL;
    gdCmp.verticalAlignment = SWT.FILL;
    gdCmp.grabExcessHorizontalSpace = true;
    gdCmp.grabExcessVerticalSpace = true;
    cmp.setLayoutData(gdCmp);
    cmp.setLayout(new GridLayout(1, false));
    JPanel chartPanel = createDemoPanel(tipo);
    Frame graphFrame = SWT_AWT.new_Frame(cmp);
    graphFrame.add(chartPanel);
    graphFrame.pack();

    GridData gdThis = new GridData(SWT.FILL);
    gdThis.horizontalAlignment = SWT.FILL;
    gdThis.verticalAlignment = SWT.FILL;
    gdThis.grabExcessHorizontalSpace = true;
    gdThis.grabExcessVerticalSpace = true;

    this.setLayoutData(gdThis);
    this.setLayout(new GridLayout(1, false));
}

From source file:AdvancedBrowser.java

public AdvancedBrowser(String location) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Advanced Browser");

    shell.setLayout(new FormLayout());

    Composite controls = new Composite(shell, SWT.NONE);
    FormData data = new FormData();
    data.top = new FormAttachment(0, 0);
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    controls.setLayoutData(data);/*from  w  w  w.  ja  v  a2 s.c o  m*/

    Label status = new Label(shell, SWT.NONE);
    data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.bottom = new FormAttachment(100, 0);
    status.setLayoutData(data);

    final Browser browser = new Browser(shell, SWT.BORDER);
    data = new FormData();
    data.top = new FormAttachment(controls);
    data.bottom = new FormAttachment(status);
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    browser.setLayoutData(data);

    controls.setLayout(new GridLayout(7, false));

    Button button = new Button(controls, SWT.PUSH);
    button.setText("Back");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.back();
        }
    });

    button = new Button(controls, SWT.PUSH);
    button.setText("Forward");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.forward();
        }
    });

    button = new Button(controls, SWT.PUSH);
    button.setText("Refresh");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.refresh();
        }
    });

    button = new Button(controls, SWT.PUSH);
    button.setText("Stop");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.stop();
        }
    });

    final Text url = new Text(controls, SWT.BORDER);
    url.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    url.setFocus();

    button = new Button(controls, SWT.PUSH);
    button.setText("Go");
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            browser.setUrl(url.getText());
        }
    });

    Label throbber = new Label(controls, SWT.NONE);
    throbber.setText(AT_REST);

    shell.setDefaultButton(button);

    browser.addCloseWindowListener(new AdvancedCloseWindowListener());
    browser.addLocationListener(new AdvancedLocationListener(url));
    browser.addProgressListener(new AdvancedProgressListener(throbber));
    browser.addStatusTextListener(new AdvancedStatusTextListener(status));

    // Go to the initial URL
    if (location != null) {
        browser.setUrl(location);
    }

    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

From source file:org.jfree.experimental.chart.swt.editor.SWTTitleEditor.java

/**
 * Standard constructor: builds a panel for displaying/editing the
 * properties of the specified title.//w w w.  ja v a 2  s  .  c om
 *
 * @param title  the title, which should be changed.
 */
SWTTitleEditor(Composite parent, int style, Title title) {
    super(parent, style);
    FillLayout layout = new FillLayout();
    layout.marginHeight = layout.marginWidth = 4;
    setLayout(layout);

    TextTitle t = (title != null ? (TextTitle) title : new TextTitle(localizationResources.getString("Title")));
    this.showTitle = (title != null);
    this.titleFont = SWTUtils.toSwtFontData(getDisplay(), t.getFont(), true);
    this.titleColor = SWTUtils.toSwtColor(getDisplay(), t.getPaint());

    Group general = new Group(this, SWT.NONE);
    general.setLayout(new GridLayout(3, false));
    general.setText(localizationResources.getString("General"));
    // row 1
    Label label = new Label(general, SWT.NONE);
    label.setText(localizationResources.getString("Show_Title"));
    GridData gridData = new GridData();
    gridData.horizontalSpan = 2;
    label.setLayoutData(gridData);
    this.showTitleCheckBox = new Button(general, SWT.CHECK);
    this.showTitleCheckBox.setSelection(this.showTitle);
    this.showTitleCheckBox.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
    this.showTitleCheckBox.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            SWTTitleEditor.this.showTitle = SWTTitleEditor.this.showTitleCheckBox.getSelection();
        }
    });
    // row 2
    new Label(general, SWT.NONE).setText(localizationResources.getString("Text"));
    this.titleField = new Text(general, SWT.BORDER);
    this.titleField.setText(t.getText());
    this.titleField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    new Label(general, SWT.NONE).setText("");
    // row 3
    new Label(general, SWT.NONE).setText(localizationResources.getString("Font"));
    this.fontField = new Text(general, SWT.BORDER);
    this.fontField.setText(this.titleFont.toString());
    this.fontField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    this.selectFontButton = new Button(general, SWT.PUSH);
    this.selectFontButton.setText(localizationResources.getString("Select..."));
    this.selectFontButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create the font-change dialog
            FontDialog dlg = new FontDialog(getShell());
            dlg.setText(localizationResources.getString("Font_Selection"));
            dlg.setFontList(new FontData[] { SWTTitleEditor.this.titleFont });
            if (dlg.open() != null) {
                // Dispose of any fonts we have created
                if (SWTTitleEditor.this.font != null) {
                    SWTTitleEditor.this.font.dispose();
                }
                // Create the new font and set it into the title 
                // label
                SWTTitleEditor.this.font = new Font(getShell().getDisplay(), dlg.getFontList());
                //titleField.setFont(font);
                SWTTitleEditor.this.fontField.setText(SWTTitleEditor.this.font.getFontData()[0].toString());
                SWTTitleEditor.this.titleFont = SWTTitleEditor.this.font.getFontData()[0];
            }
        }
    });
    // row 4
    new Label(general, SWT.NONE).setText(localizationResources.getString("Color"));
    // Use a SwtPaintCanvas to show the color, note that we must set the 
    // heightHint.
    final SWTPaintCanvas colorCanvas = new SWTPaintCanvas(general, SWT.NONE, this.titleColor);
    GridData canvasGridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    canvasGridData.heightHint = 20;
    colorCanvas.setLayoutData(canvasGridData);
    this.selectColorButton = new Button(general, SWT.PUSH);
    this.selectColorButton.setText(localizationResources.getString("Select..."));
    this.selectColorButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create the color-change dialog
            ColorDialog dlg = new ColorDialog(getShell());
            dlg.setText(localizationResources.getString("Title_Color"));
            dlg.setRGB(SWTTitleEditor.this.titleColor.getRGB());
            RGB rgb = dlg.open();
            if (rgb != null) {
                // create the new color and set it to the 
                // SwtPaintCanvas
                SWTTitleEditor.this.titleColor = new Color(getDisplay(), rgb);
                colorCanvas.setColor(SWTTitleEditor.this.titleColor);
            }
        }
    });
}

From source file:org.eclipse.swt.examples.controlexample.ShellTab.java

/**
 * Creates the "Control" widget children.
 *///  ww w.j a v a 2  s  .  c  om
@Override
void createControlWidgets() {

    /* Create the parent style buttons */
    noParentButton = new Button(parentStyleGroup, SWT.RADIO);
    noParentButton.setText(ControlExample.getResourceString("No_Parent"));
    parentButton = new Button(parentStyleGroup, SWT.RADIO);
    parentButton.setText(ControlExample.getResourceString("Parent"));

    /* Create the decoration style buttons */
    noTrimButton = new Button(styleGroup, SWT.CHECK);
    noTrimButton.setText("SWT.NO_TRIM");
    noMoveButton = new Button(styleGroup, SWT.CHECK);
    noMoveButton.setText("SWT.NO_MOVE");
    closeButton = new Button(styleGroup, SWT.CHECK);
    closeButton.setText("SWT.CLOSE");
    titleButton = new Button(styleGroup, SWT.CHECK);
    titleButton.setText("SWT.TITLE");
    minButton = new Button(styleGroup, SWT.CHECK);
    minButton.setText("SWT.MIN");
    maxButton = new Button(styleGroup, SWT.CHECK);
    maxButton.setText("SWT.MAX");
    borderButton = new Button(styleGroup, SWT.CHECK);
    borderButton.setText("SWT.BORDER");
    resizeButton = new Button(styleGroup, SWT.CHECK);
    resizeButton.setText("SWT.RESIZE");
    onTopButton = new Button(styleGroup, SWT.CHECK);
    onTopButton.setText("SWT.ON_TOP");
    toolButton = new Button(styleGroup, SWT.CHECK);
    toolButton.setText("SWT.TOOL");
    sheetButton = new Button(styleGroup, SWT.CHECK);
    sheetButton.setText("SWT.SHEET");
    Label separator = new Label(styleGroup, SWT.SEPARATOR | SWT.HORIZONTAL);
    separator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    shellTrimButton = new Button(styleGroup, SWT.CHECK);
    shellTrimButton.setText("SWT.SHELL_TRIM");
    dialogTrimButton = new Button(styleGroup, SWT.CHECK);
    dialogTrimButton.setText("SWT.DIALOG_TRIM");

    /* Create the modal style buttons */
    modelessButton = new Button(modalStyleGroup, SWT.RADIO);
    modelessButton.setText("SWT.MODELESS");
    primaryModalButton = new Button(modalStyleGroup, SWT.RADIO);
    primaryModalButton.setText("SWT.PRIMARY_MODAL");
    applicationModalButton = new Button(modalStyleGroup, SWT.RADIO);
    applicationModalButton.setText("SWT.APPLICATION_MODAL");
    systemModalButton = new Button(modalStyleGroup, SWT.RADIO);
    systemModalButton.setText("SWT.SYSTEM_MODAL");

    /* Create the 'other' buttons */
    imageButton = new Button(otherGroup, SWT.CHECK);
    imageButton.setText(ControlExample.getResourceString("Image"));
    backgroundImageButton = new Button(otherGroup, SWT.CHECK);
    backgroundImageButton.setText(ControlExample.getResourceString("BackgroundImage"));

    createSetGetGroup();

    /* Create the "create" and "closeAll" buttons */
    createButton = new Button(controlGroup, SWT.NONE);
    GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
    createButton.setLayoutData(gridData);
    createButton.setText(ControlExample.getResourceString("Create_Shell"));
    closeAllButton = new Button(controlGroup, SWT.NONE);
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    closeAllButton.setText(ControlExample.getResourceString("Close_All_Shells"));
    closeAllButton.setLayoutData(gridData);

    /* Add the listeners */
    createButton.addSelectionListener(widgetSelectedAdapter(e -> createButtonSelected(e)));
    closeAllButton.addSelectionListener(widgetSelectedAdapter(e -> closeAllShells()));
    SelectionListener decorationButtonListener = widgetSelectedAdapter(
            event -> decorationButtonSelected(event));
    noTrimButton.addSelectionListener(decorationButtonListener);
    noMoveButton.addSelectionListener(decorationButtonListener);
    closeButton.addSelectionListener(decorationButtonListener);
    titleButton.addSelectionListener(decorationButtonListener);
    minButton.addSelectionListener(decorationButtonListener);
    maxButton.addSelectionListener(decorationButtonListener);
    borderButton.addSelectionListener(decorationButtonListener);
    resizeButton.addSelectionListener(decorationButtonListener);
    dialogTrimButton.addSelectionListener(decorationButtonListener);
    shellTrimButton.addSelectionListener(decorationButtonListener);
    applicationModalButton.addSelectionListener(decorationButtonListener);
    systemModalButton.addSelectionListener(decorationButtonListener);

    /* Set the default state */
    noParentButton.setSelection(true);
    modelessButton.setSelection(true);
}

From source file:com.rcp.wbw.demo.editor.SWTTitleEditor.java

/**
 * Standard constructor: builds a panel for displaying/editing the
 * properties of the specified title./*  w w w  .  ja  v a  2 s. co  m*/
 * 
 * @param parent
 *            the parent.
 * @param style
 *            the style.
 * @param title
 *            the title, which should be changed.
 * 
 */
SWTTitleEditor(Composite parent, int style, Title title) {
    super(parent, style);
    FillLayout layout = new FillLayout();
    layout.marginHeight = layout.marginWidth = 4;
    setLayout(layout);

    TextTitle t = (title != null ? (TextTitle) title : new TextTitle(localizationResources.getString("Title")));
    this.showTitle = (title != null);
    this.titleFont = SWTUtils.toSwtFontData(getDisplay(), t.getFont(), true);
    this.titleColor = SWTUtils.toSwtColor(getDisplay(), t.getPaint());

    Group general = new Group(this, SWT.NONE);
    general.setLayout(new GridLayout(3, false));
    general.setText(localizationResources.getString("General"));
    // row 1
    Label label = new Label(general, SWT.NONE);
    label.setText(localizationResources.getString("Show_Title"));
    GridData gridData = new GridData();
    gridData.horizontalSpan = 2;
    label.setLayoutData(gridData);
    this.showTitleCheckBox = new Button(general, SWT.CHECK);
    this.showTitleCheckBox.setSelection(this.showTitle);
    this.showTitleCheckBox.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
    this.showTitleCheckBox.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            SWTTitleEditor.this.showTitle = SWTTitleEditor.this.showTitleCheckBox.getSelection();
        }
    });
    // row 2
    new Label(general, SWT.NONE).setText(localizationResources.getString("Text"));
    this.titleField = new Text(general, SWT.BORDER);
    this.titleField.setText(t.getText());
    this.titleField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    new Label(general, SWT.NONE).setText("");
    // row 3
    new Label(general, SWT.NONE).setText(localizationResources.getString("Font"));
    this.fontField = new Text(general, SWT.BORDER);
    this.fontField.setText(this.titleFont.toString());
    this.fontField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    this.selectFontButton = new Button(general, SWT.PUSH);
    this.selectFontButton.setText(localizationResources.getString("Select..."));
    this.selectFontButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create the font-change dialog
            FontDialog dlg = new FontDialog(getShell());
            dlg.setText(localizationResources.getString("Font_Selection"));
            dlg.setFontList(new FontData[] { SWTTitleEditor.this.titleFont });
            if (dlg.open() != null) {
                // Dispose of any fonts we have created
                if (SWTTitleEditor.this.font != null) {
                    SWTTitleEditor.this.font.dispose();
                }
                // Create the new font and set it into the title
                // label
                SWTTitleEditor.this.font = new Font(getShell().getDisplay(), dlg.getFontList());
                // titleField.setFont(font);
                SWTTitleEditor.this.fontField.setText(SWTTitleEditor.this.font.getFontData()[0].toString());
                SWTTitleEditor.this.titleFont = SWTTitleEditor.this.font.getFontData()[0];
            }
        }
    });
    // row 4
    new Label(general, SWT.NONE).setText(localizationResources.getString("Color"));
    // Use a SwtPaintCanvas to show the color, note that we must set the
    // heightHint.
    final SWTPaintCanvas colorCanvas = new SWTPaintCanvas(general, SWT.NONE, this.titleColor);
    GridData canvasGridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    canvasGridData.heightHint = 20;
    colorCanvas.setLayoutData(canvasGridData);
    this.selectColorButton = new Button(general, SWT.PUSH);
    this.selectColorButton.setText(localizationResources.getString("Select..."));
    this.selectColorButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            // Create the color-change dialog
            ColorDialog dlg = new ColorDialog(getShell());
            dlg.setText(localizationResources.getString("Title_Color"));
            dlg.setRGB(SWTTitleEditor.this.titleColor.getRGB());
            RGB rgb = dlg.open();
            if (rgb != null) {
                // create the new color and set it to the
                // SwtPaintCanvas
                SWTTitleEditor.this.titleColor = new Color(getDisplay(), rgb);
                colorCanvas.setColor(SWTTitleEditor.this.titleColor);
            }
        }
    });
}