0
我正在尝试设置StyledText窗口小部件的BorderColor。 StyleRange Object允许我设置字段borderColor和borderStyle。使用StyleRange设置StyledText BorderColor
我的代码如下所示:
StyledText test = new StyledText(parent, SWT.BORDER);
Display display = Display.getCurrent();
Color color = display.getSystemColor(SWT.COLOR_RED);
StyleRange style = new StyleRange();
style.borderColor = color;
style.borderStyle = SWT.BORDER_SOLID;
test.setStyleRange(style);
但这代码并没有设置边框的颜色。我知道有一种解决方法是使用画笔侦听器,但为什么上面的示例不起作用?
感谢澄清!我认为StyleRange也可以用于整个控件。然后我坚持按照[这里]描述的Paint Listener方法(http://stackoverflow.com/questions/11522774/draw-outline-border-on-text-component)。 –