Change group widget title color in SWT

I have a SWT window in which there is a Group widget in which I placed a couple of other widgets, I set the name of the group and its working tone. The color of the name of the group is always blue (in my case I'm not sure), and this does not synchronize with other children within the group. So I wonder if there is a way to change the color of the text and the font of the name of the group, if there is a way?

+4
source share
2 answers

It is very easy to change the font of a group, check this fragment (using a fragment from 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 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 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

font change on group in W7

But, as you can see, changing the color to setForeground(Color c) does not change the thing when I look for more information. I found a bug report in SWT bugzilla The color of the group control header cannot be changed . This is a Windows platform specific error.

+5
source

But you can try a group without text + a Label widget, this may be the solution if you need only the best GUI.

+1
source

All Articles