我有一个SWT窗口,其中有组小部件,其中我放置了几个其他小部件,我设置组的标题及其工作正常.组标题颜色总是蓝色(在我的情况下,我不确定),并且不与组内的其他子项同步.所以我想知道是否有一种方法来更改组标题文本颜色和字体,如果有一个办法 ?
更改组的字体非常容易,请检查此片段(来自java2s.com的已使用片段)
//Send questions, comments, bug reports, etc. to the authors:
//Rob Warner (rwarner@interspatial.com)
//Robert Harris (rbrt_harris@yahoo.com)
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
/**
* This class demonstrates groups
*/
public class GroupExample {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout());
// Create the first group
Group group1 = new Group(shell, SWT.SHADOW_IN);
group1.setText("Who's your favorite?");
group1.setLayout(new RowLayout(SWT.VERTICAL));
group1.setFont(new Font(display, "Consolas", 10, SWT.BOLD));
new Button(group1, SWT.RADIO).setText("John");
new Button(group1, SWT.RADIO).setText("Paul");
new Button(group1, SWT.RADIO).setText("George");
new Button(group1, SWT.RADIO).setText("Ringo");
// Create the second group
Group group2 = new Group(shell, SWT.NO_RADIO_GROUP);
group2.setText("Who's your favorite?");
group2.setLayout(new RowLayout(SWT.VERTICAL));
group2.setForeground(new Color(display, new RGB(255, 0, 0)));
new Button(group2, SWT.RADIO).setText("Barry");
new Button(group2, SWT.RADIO).setText("Robin");
new Button(group2, SWT.RADIO).setText("Maurice");
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
Run Code Online (Sandbox Code Playgroud)
它在W7上提供此行为

但正如你所看到的,颜色的setForeground(Color c)变化不会改变一件事,当我搜索其他信息时,我发现了关于SWT bugzilla 的错误报告组控件的标题颜色无法更改.这是Windows平台依赖的bug.
| 归档时间: |
|
| 查看次数: |
3855 次 |
| 最近记录: |