Example usage for org.eclipse.swt.widgets Button setToolTipText

List of usage examples for org.eclipse.swt.widgets Button setToolTipText

Introduction

In this page you can find the example usage for org.eclipse.swt.widgets Button setToolTipText.

Prototype

public void setToolTipText(String toolTipText) 

Source Link

Document

Sets the receiver's tool tip text to the argument, which may be null indicating that no tool tip text should be shown.

Usage

From source file:CalculatorMichaelSchmidt.java

@Override
protected Control createDialogArea(final Composite parent) {
    Composite container = (Composite) super.createDialogArea(parent);
    final GridLayout calculatorGridLayout = new GridLayout();
    calculatorGridLayout.marginRight = 5;
    calculatorGridLayout.marginLeft = 5;
    calculatorGridLayout.marginBottom = 5;
    calculatorGridLayout.marginTop = 5;/*from w ww  . j a v a  2  s  . com*/
    calculatorGridLayout.marginWidth = 10;
    calculatorGridLayout.marginHeight = 2;
    calculatorGridLayout.numColumns = 4;
    calculatorGridLayout.verticalSpacing = 2;
    calculatorGridLayout.makeColumnsEqualWidth = true;
    calculatorGridLayout.horizontalSpacing = 2;
    container.setLayout(calculatorGridLayout);

    // The display.  Note that it has a limit of 30 characters, 
    // much greater than the length of a double-precision number. 
    displayText = new Text(container, SWT.RIGHT | SWT.BORDER);
    displayText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
    displayText.setEditable(false);
    displayText.setDoubleClickEnabled(false);
    displayText.setTextLimit(30);
    displayText.setText(displayString);
    displayText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 4, 1));

    final Button msButton = new Button(container, SWT.NONE);
    msButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateMemory('S');
        }
    });
    msButton.setToolTipText("Save value to Memory");
    msButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    msButton.setText("MS");

    final Button mcButton = new Button(container, SWT.NONE);
    mcButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('D');
        }
    });
    mcButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    mcButton.setToolTipText("Clear Memory");
    mcButton.setText("MC");

    final Button clearButton = new Button(container, SWT.NONE);
    clearButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('C');
        }
    });
    clearButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    clearButton.setToolTipText("Clear all Calculator Registers");
    clearButton.setText("C");

    final Button ceButton = new Button(container, SWT.NONE);
    ceButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('E');
        }
    });
    ceButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    ceButton.setToolTipText("Clear Entry");
    ceButton.setText("CE");

    final Button memAddButton = new Button(container, SWT.NONE);
    memAddButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateMemory('+');
        }
    });
    memAddButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    memAddButton.setToolTipText("Add value to Memory");
    memAddButton.setText("M+");

    final Button mrButton = new Button(container, SWT.NONE);
    mrButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('R');
        }
    });
    mrButton.setToolTipText("Recall value in Memory");
    mrButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    mrButton.setText("MR");

    final Button backButton = new Button(container, SWT.NONE);
    backButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('B');
        }
    });
    backButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    backButton.setToolTipText("Backspace");
    backButton.setText("BACK");

    final Button divideButton = new Button(container, SWT.NONE);
    divideButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateCalc('/');
        }
    });
    divideButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    divideButton.setToolTipText("Divide");
    divideButton.setText("/");

    final Button memSubtractButton = new Button(container, SWT.NONE);
    memSubtractButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateMemory('-');
        }
    });
    memSubtractButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    memSubtractButton.setToolTipText("Subtract value from Memory");
    memSubtractButton.setText("M-");

    final Button inverseButton = new Button(container, SWT.NONE);
    inverseButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('I');
        }
    });
    inverseButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    inverseButton.setToolTipText("Inverse of value");
    inverseButton.setText("1/X");

    final Button sqrtButton = new Button(container, SWT.NONE);
    sqrtButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('Q');
        }
    });
    sqrtButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    sqrtButton.setToolTipText("Square Root of value");
    sqrtButton.setText("SQRT");

    final Button multiplyButton = new Button(container, SWT.NONE);
    multiplyButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateCalc('*');
        }
    });
    multiplyButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    multiplyButton.setToolTipText("Multiply");
    multiplyButton.setText("*");

    final Button num7Button = new Button(container, SWT.NONE);
    num7Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('7');
        }
    });
    num7Button.setToolTipText("Numeric Pad");
    num7Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num7Button.setText("7");

    final Button num8Button = new Button(container, SWT.NONE);
    num8Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('8');
        }
    });
    num8Button.setToolTipText("Numeric Pad");
    num8Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num8Button.setText("8");

    final Button num9Button = new Button(container, SWT.NONE);
    num9Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('9');
        }
    });
    num9Button.setToolTipText("Numeric Pad");
    num9Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num9Button.setText("9");

    final Button SubtractButton = new Button(container, SWT.NONE);
    SubtractButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateCalc('-');
        }
    });
    SubtractButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    SubtractButton.setToolTipText("Subtract");
    SubtractButton.setText("-");

    final Button num4Button = new Button(container, SWT.NONE);
    num4Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('4');
        }
    });
    num4Button.setToolTipText("Numeric Pad");
    num4Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num4Button.setText("4");

    final Button num5Button = new Button(container, SWT.NONE);
    num5Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('5');
        }
    });
    num5Button.setToolTipText("Numeric Pad");
    num5Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num5Button.setText("5");

    final Button num6Button = new Button(container, SWT.NONE);
    num6Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('6');
        }
    });
    num6Button.setToolTipText("Numeric Pad");
    num6Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num6Button.setText("6");

    final Button AdditionButton = new Button(container, SWT.NONE);
    AdditionButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateCalc('+');
        }
    });
    AdditionButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    AdditionButton.setToolTipText("Add");
    AdditionButton.setText("+");

    final Button num1Button = new Button(container, SWT.NONE);
    num1Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('1');
        }
    });
    num1Button.setCapture(true);
    num1Button.setToolTipText("Numeric Pad");
    num1Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num1Button.setText("1");

    final Button num2Button = new Button(container, SWT.NONE);
    num2Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('2');
        }
    });
    num2Button.setToolTipText("Numeric Pad");
    num2Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num2Button.setText("2");

    final Button num3Button = new Button(container, SWT.NONE);
    num3Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('3');
        }
    });
    num3Button.setToolTipText("Numeric Pad");
    num3Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num3Button.setText("3");

    final Button equalsButton = new Button(container, SWT.NONE);
    equalsButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateCalc('=');
        }
    });
    equalsButton.setToolTipText("Equals (get result)");
    equalsButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 2));
    equalsButton.setText("=");

    final Button num0Button = new Button(container, SWT.NONE);
    num0Button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('0');
        }
    });
    num0Button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    num0Button.setToolTipText("Numeric Pad");
    num0Button.setText("0");

    final Button decimalButton = new Button(container, SWT.NONE);
    decimalButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('.');
        }
    });
    decimalButton.setToolTipText("Numeric Pad");
    decimalButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    decimalButton.setText(".");

    final Button signButton = new Button(container, SWT.NONE);
    signButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(final SelectionEvent e) {
            updateDisplay('-');
        }
    });
    signButton.setToolTipText("Change sign of value");
    signButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    signButton.setText("+/-");
    new Label(container, SWT.NONE);
    //
    return container;
}

From source file:PrintKTableExample.java

/**
 * Fugt einen Button zur Leiste hinzu. Gibt eine Referenz auf den angelegten
 * Button zuruck./*from   ww w .  j  ava  2 s  . c o  m*/
 */
public Button addButton(String name, String toolTip, SelectionListener selListener) {
    Button b = new Button(this, SWT.PUSH);
    b.setText(name);
    b.setToolTipText(toolTip);
    b.setLayoutData(new RowData(myButtonWidth, 25));
    if (selListener != null)
        b.addSelectionListener(selListener);
    myButtons.add(b);
    return b;
}

From source file:PrintKTableExample.java

protected Button addButton(boolean rightAdjusted, String text, String tip) {
    Button erg = new Button(guiButtonArea, SWT.PUSH);
    erg.setText(text);//from  w  w w  .j a v  a  2s. c  o m
    erg.setToolTipText(tip);

    Point butPrefferedSize = erg.computeSize(SWT.DEFAULT, SWT.DEFAULT);

    FormData fd = new FormData();
    fd.bottom = new FormAttachment(100, -3);

    if (butPrefferedSize.x > 70)
        fd.width = butPrefferedSize.x + 4;
    else
        fd.width = 70;
    fd.height = 24;
    erg.setLayoutData(fd);

    if (rightAdjusted) {
        if (guiLastRightBut == null)
            fd.right = new FormAttachment(100, -3);
        else
            fd.right = new FormAttachment(guiLastRightBut, -3);
        guiLastRightBut = erg;
    } else {
        if (guiLastLeftBut == null)
            fd.left = new FormAttachment(0, 3);
        else
            fd.left = new FormAttachment(guiLastLeftBut, 3);
        guiLastLeftBut = erg;
    }

    erg.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent arg0) {
            onButton((Button) arg0.widget, ((Button) arg0.widget).getText());
        }
    });
    return erg;
}