首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

定做tooltip

2013-10-27 
定制tooltippublic class HelloToolTip {public static void main(String[] args) {Display display new

定制tooltip
public class HelloToolTip { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Hello table"); shell.setLayout(new RowLayout()); shell.setSize(300, 200); Text text = new Text(shell, SWT.BORDER); text.setToolTipText("Hello,text!"); ToolTip toolTip = new ToolTip(shell, ToolTip.NO_RECREATE, true) { protected Composite createToolTipContentArea(Event event, Composite parent) { // Create the content area Composite composite = new Composite(parent, SWT.NONE); composite.setBackground(parent.getDisplay().getSystemColor( SWT.COLOR_INFO_BACKGROUND)); Text text = new Text(composite, SWT.READ_ONLY); text.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); text.setText("custom tooltip,text!"); GridLayoutFactory.fillDefaults().margins(2, 2).generateLayout(composite); return composite; } };// toolTip.setHideOnMouseDown(false);// toolTip.setHideDelay(1000); toolTip.setPopupDelay(0); toolTip.activate(); shell.open(); while(!shell.isDisposed()){ if(!display.readAndDispatch()){ display.sleep(); } } display.dispose(); } }

?

热点排行