Montag, 9. August 2010

Tooltip enabled CCombo for SWT

After if did a lot of research about a tooltip enabled combo box in SWT I came across several issue reports in the offical issue tracker. There they stated that there will be no tooltip enabled combo box.
So I decied to do it my own because we had a great need for it. 

Et voilá, here it is:
http://download.planethost.de/code/TooltipCCombo.java

Use at your own risk. Tested with Eclipse 3.6 on Windows and Linux.

 Screenshot from TooltipCCombo in action.










A short snippet for the shell shown above:
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class Snippet {

public static void main (String [] args) {
    Display display = new Display ();
    Shell shell = new Shell (display);
    shell.setLayout (new RowLayout ());
    
    TooltipCCombo combo = new TooltipCCombo(shell, SWT.READ_ONLY | SWT.BORDER);
    combo.add("first", "first tooltip");
    combo.add("second", "second tooltip");
    combo.add("fourth", "fourthtooltip");
    combo.add("thrid", 2, "third tooltip");
    
    shell.pack ();
    shell.open ();
    while (!shell.isDisposed ()) {
        if (!display.readAndDispatch ()) display.sleep ();
    }
    display.dispose ();
}
} 

Keine Kommentare:

Kommentar veröffentlichen