public void createPartControl(Composite parent) {
final Composite top = new Composite(parent, SWT.NONE);
GridLayout topLayout = new GridLayout(2, false);
top.setLayout(topLayout);
Label label = new Label(top, SWT.NONE);
label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false,false));
label.setText("Name:");
final Text text = new Text(top, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
text.setText("");
final Color bgColor = PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_RED);
final Color fgColor = PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_BLACK);
final AtomicReference x = new AtomicReference();
final AtomicReference y = new AtomicReference();
text.addMouseTrackListener(new MouseTrackAdapter(){
public void mouseHover(MouseEvent e) {
x.set(e.x);
y.set(e.y);
text.redraw();
}
});
text.addPaintListener(new PaintListener(){
public void paintControl(PaintEvent e) {
GC gc = e.gc;
if(x.get() != null && y.get() != null){
Rectangle rect = new Rectangle(x.get(),y.get(),100,20);
gc.setBackground(bgColor);
gc.setForeground(fgColor);
gc.fillRectangle(rect);
gc.drawText("Hello, it works!", rect.x, rect.y);
}
}
});
}