Set color for SWT expand bar

60 Views Asked by At

I am using expand bar in an eclipse application UI. The default color of expand bar item is light grey and I need to change the background color of expand bar item using SWT java.

I have tried setting the background color of expand bar, but that'll change the overall background of expand bar ( dark grey in the image ). And setting the foreground color of expand bar, will change the text color. There is no method to set the background& foreground color of expand bar item.

The color of expand bar is dark grey, which requires no change & the expand bar item is light grey, which needs to be changed.

The code for setting expand bar & it's item is as follows -

 final ExpandBar expandBar = new ExpandBar(iconAndButtonComposite, SWT.V_SCROLL);
 expandBar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
 Color backgroundColor = parent.getBackground();
 expandBar.setBackground(backgroundColor);

 RGB color = new RGB(0, 114, 118);
 RGB grayColor = new RGB(230, 230, 230);
 expandBar.setForeground(new Color(parent.getDisplay(), color)); //This will set text color
 expandBar.setBackground(new Color(parent.getDisplay(), grayColor));
     

 final ExpandItem expandItem = new ExpandItem(expandBar, SWT.NONE);
 expandItem.setText(Constants.ODATAV2_EXPAND_ITEM);
     odataV2Viewer = new SAPEntityViewerPage(odataV2Selection);
 odataV2Viewer.generateCheckBoxViewer(expandBar, expandItem);
 expandItem.setExpanded(true);

 final ExpandItem expandItem1 = new ExpandItem(expandBar, SWT.NONE);
 expandItem1.setText(Constants.ODATAV4_EXPAND_ITEM);
 expandItem1.setExpanded(false);
 odataV4Viewer = new SAPEntityViewerPage(odataV4Selection);
 odataV4Viewer.generateCheckBoxViewer(expandBar, expandItem1);

 final ExpandItem expandItem2 = new ExpandItem(expandBar, SWT.NONE);
 expandItem2.setText(Constants.SOAP_EXPAND_ITEM);
 soapViewer = new SAPEntityViewerPage(odataV4Selection);
 filePath = soapViewer.generateSoapUploader(expandBar, expandItem2, wsdlFileMap);

I've tried adding paint listner to expand item, but that didn't work. Any other way to set the background color of expand bar item ?

0

There are 0 best solutions below