【问题标题】:Multiline tooltip for Nebula Grid星云网格的多行工具提示
【发布时间】:2014-07-09 15:38:52
【问题描述】:

我正在研究星云网格表。我返回到getToolTipText() 方法的字符串不适合多行,同时它显示在单行中。我正在使用以下代码来实现 Multiline 工具提示。但我仍然在一行中得到那个字符串。

ColumnViewerToolTipSupport toolTipSupport = new ColumnViewerToolTipSupport(col.getViewer(), SWT.NONE, false) {
        @Override
        protected Composite createToolTipContentArea(Event event, Composite parent) {
            Composite comp = new Composite(parent, SWT.NONE);
            comp.setLayout(new FillLayout());
            comp.setBounds(0, 0, 250, 250);

            Text b = new Text(comp, SWT.LEFT);
            b.setText(getText(event));
            Activator.log("Text: " + getText(event), Status.INFO);
            b.setBackground(new Color(null, 255, 0, 0));
            b.setSize(250, 250);
            // b.addSelectionListener(new SelectionAdapter() {
            // @Override
            // public void widgetSelected(SelectionEvent e) {
            // hide();
            // MessageBox box = new MessageBox(.getShell(),SWT.ICON_INFORMATION);
            // box.setMessage("Hello World!");
            // box.setText("Hello World");
            // box.open();
            // }
            // });
            return comp;
        }



    };

【问题讨论】:

    标签: java grid swt jface nebula


    【解决方案1】:

    如果要支持多行,则需要在Text 控件上指定SWT.MULTI 样式。

    如果您想换行较长的行,也请指定 SWT.WRAP 样式。

    所以:

    Text b = new Text(comp, SWT.LEFT | SWT.MULTI | SWT.WRAP);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-17
      • 2021-05-29
      • 1970-01-01
      • 1970-01-01
      • 2023-02-25
      • 1970-01-01
      • 2014-12-08
      • 2018-10-25
      相关资源
      最近更新 更多