title: SWT - Transparent Radio Button inside Table
body: <p>I can't for the life of me figure out how to make an SWT radio button cell use the current underlying mechanism for determining 'alternating row' colors and 'selected row' colors in a table.</p>
  
  <p>The table (by default?) already has the alternating/selected row colors working and all other columns/rows correctly display them. Note - I've been digging around through the code but can't figure out how the alternate/selected row colors are getting set. One would assume it's the ColumnLabelProvider, but it's not. I see an example of how to manually set the alternating colors in the link below, but I want to avoid doing that because I wouldn't be using whatever architecture is already being used under the hood.</p>
  
  <ul>
  <li><a href="http://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/examples/org.eclipse.jface.snippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippets/viewers/Snippet041TableViewerAlternatingColors.java" rel="nofollow">http://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/examples/org.eclipse.jface.snippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippets/viewers/Snippet041TableViewerAlternatingColors.java</a></li>
  </ul>
  
  <p>A code sample is provided below.  Any help would be appreciated!!</p>
  
  <pre><code>private Map&lt;Object, Button&gt; buttons = new HashMap&lt;&gt;();
  ...
  
  private void createColumns(final TableViewer viewer) {
      final TableViewerColumn column0 = new TableViewerColumn(viewer, SWT.CENTER);
      column0.getColumn().setWidth(50);
      column0.getColumn().setText("MyColumnTitle");
      column0.setLabelProvider(new ColumnLabelProvider() {
  
          @Override
          public void update(final ViewerCell cell) {
              cell.setImage(null);
              cell.setText(null);
  
              Button button;
              if (buttons.containsKey(cell.getElement())) {
                  button = buttons.get(cell.getElement());
              } else {
                  final TableItem item = (TableItem) cell.getItem();
                  button = new Button((Composite) cell.getViewerRow().getControl(), SWT.RADIO);
                  buttons.put(cell.getElement(), button);
  
                  // Make the radio button clickable
                  final TableEditor editor = new TableEditor(item.getParent());
                  editor.horizontalAlignment = SWT.LEFT;
                  editor.grabHorizontal = true;
                  editor.minimumWidth = 50;                    
                  editor.setEditor(button, item, cell.getColumnIndex());
                  editor.layout();
              }
  
  // Some things I have tried without success                
  // button.setBackground(null);
  // button.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
  // cell.getViewerRow().getControl().getParent().setBackgroundMode(SWT.INHERIT_NONE);
  // cell.setBackground(cell.getNeighbor(ViewerCell.RIGHT, true).getBackground());
  // cell.setForeground(cell.getNeighbor(ViewerCell.RIGHT, true).getForeground());
          }
      });
  
      // This is a column that works fine (shows alternating rows/highlighting as expected)
      final TableViewerColumn column = new TableViewerColumn(viewer, SWT.LEFT);
      column.getColumn().setWidth(240);
      column.getColumn().setText("ColumnName");
      column.setLabelProvider(new ColumnLabelProvider() {
          @Override
          public String getText(final Object element) {
              if (element instanceof MyObject) {
                  return MyObject.getText();
              }
              return super.getText(element);
          }
      });
  </code></pre>