Mega Code Archive

 
Categories / Java Tutorial / SWT
 

Add ToolTip to ToolItem

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 ToolItemToolTip {   public static void main(String[] args) {     Display display = new Display();     Shell shell = new Shell(display);     ToolBar bar = new ToolBar(shell, SWT.BORDER);     bar.setBounds(0, 20, 200, 64);     ToolItem item1 = new ToolItem(bar, 0);     item1.setToolTipText("ToolItem \n toolTip");     shell.open();     while (!shell.isDisposed()) {       if (!display.readAndDispatch())         display.sleep();     }     display.dispose();   } }