Reputation: 5156
I have an SWT window wherein there is Group widget in which i placed couple of other widgets,i set the title of group & its working fine. The group title color is blue always(in my case i am not sure) and that doesn't sync up with other children inside group.So i wonder if there is a way to change the group title text color and font if there is a way ?
Upvotes: 4
Views: 4401
Reputation: 11
But you can try a Group without text + a Label widget, this maybe a solution if you just want a better GUI.
Upvotes: 1
Reputation: 4843
It's quite easy to change font of group, check this snippet (used snippet from java2s.com)
//Send questions, comments, bug reports, etc. to the authors:
//Rob Warner ([email protected])
//Robert Harris ([email protected])
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();
}
}
It provides this behavior on W7
But as you can see, change of color by setForeground(Color c)
doesn't change a thing, when I search for additional info I found bug report on SWT bugzilla The color of the title of the group control cannot be changed. It's windows platform dependent bug.
Upvotes: 5