简体   繁体   English

RCP应用程序/ SWT标签为粗体

[英]RCP Application/SWT Label BOLD

It is a RCP application, you have a (a) LIST of Names, it is downloaded by means of a FOR loop. 这是一个RCP应用程序,您有一个(a)名称列表,它是通过FOR循环下载的。

That is to say they are Menu items and that they are located to the left of the screen with its respective layer (composite). 也就是说,它们是菜单项,它们位于屏幕的左侧,并带有其各自的图层(复合)。

Now, this works, the difficulty / what is needed here is that when you double-click on an Item it receives a "SWT.BOLD" character and when you click on another Item, the previous one receives SWT.NONE and the chosen one SWT.BOLD. 现在,这可行,困难/这里需要的是,当您双击某个项目时,它会收到一个“ SWT.BOLD”字符,而当您单击另一个项目时,上一个项目会收到SWT.NONE,而所选择的项目SWT.BOLD。 A highlighten .... 突出显示....

Here Code: 此处代码:

for (int i = 0; i < 2; i++) {
        final Label l1 = neueLabel(shell, "label "+i, i);
        l1.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseDoubleClick(MouseEvent e) {
                if(e.button==1)
                    l1.setFont(SWTResourceManager.getFont("Segoe UI", 9, 
                               SWT.BOLD));
            }
        });
    } 

Tanks 坦克

You need to save your currently highlighted label and reset its font. 您需要保存当前突出显示的标签并重置其字体。 Assuming your class has a private Label current; 假设您的班级拥有private Label current;private Label current; your overwritten method may look like 您覆盖的方法可能看起来像

if (e.button == 1) {
    if (current != null)
        current.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.NONE));
    l1.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
    current = l1;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM