ToolItem: setText(String text) : ToolItem « org.eclipse.swt.widgets « Java by API






ToolItem: setText(String text)


import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;

public class MainClass {

  public static void main(String[] a) {
    Display d = new Display();
    Shell s = new Shell(d);

    final ToolBar bar = new ToolBar(s, SWT.HORIZONTAL);
    bar.setSize(300, 70);
    bar.setLocation(0, 0);

    // create images for toolbar buttons
    // final Image saveIcon = new Image(d, "c:\\icons\\save.jpg");
    // final Image openIcon = new Image(d, "c:\\icons\\open.jpg");
    // final Image cutIcon = new Image(d, "c:\\icons\\cut.jpg");
    // final Image copyIcon = new Image(d, "c:\\icons\\copy.jpg");
    // final Image pasteIcon = new Image(d, "c:\\icons\\paste.jpg");

    // create and add the button for performing an open operation
    final ToolItem openToolItem = new ToolItem(bar, SWT.PUSH);
    // openToolItem.setImage(openIcon);
    openToolItem.setText("Open");
    openToolItem.setToolTipText("Open File");

    // create and add the button for performing a save operation
    final ToolItem saveToolItem = new ToolItem(bar, SWT.PUSH);
    // saveToolItem.setImage(saveIcon);
    saveToolItem.setText("Save");
    saveToolItem.setToolTipText("Save File");
    s.open();
    while (!s.isDisposed()) {
      if (!d.readAndDispatch())
        d.sleep();
    }
    d.dispose();
  }
}

           
       








Related examples in the same category

1.new ToolItem(ToolBar toolBar, int style)
2.ToolItem: addSelectionListener(SelectionListener lis)
3.ToolItem: setToolTipText(String text)