Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get rid of ugly SWT button fringes in Windows 7?
    text
    copied!<p>I maintain a <strong>SWT/JFace</strong> application that has to run in <strong>Windows XP</strong> as well as <strong>Windows 7</strong>. The application has a <code>TabFolder</code> that contains a <code>Composite</code>, that in turn contains the widgets. Nothing unusual and everything works well except for...</p> <hr> <h2>The Buttons</h2> <p>While they look OK in Windows XP they have an ugly grey border in Windows 7.</p> <p><img src="https://i.stack.imgur.com/IRX5T.png" alt="enter image description here"> <img src="https://i.stack.imgur.com/PGPXd.png" alt="enter image description here"></p> <hr> <p><img src="https://i.stack.imgur.com/gY0Ho.png" alt="enter image description here"></p> <p>I could set the background of the button manually but I failed to figure out a way to find out the parents actual background color. <code>getBackground()</code> returns always 240, 240, 240 even if the background is actually white.</p> <p>I found out that in Windows XP the background of a TabFolder is the theme color <strong>3D Objects</strong> while in Windows 7 there is not such correspondence. I tried to set every single theme color to bright red but the TabFolder background color was unimpressed.</p> <p>So the SWT buttons don't set their background color correctly themselves and I see no way to find out the correct color programatically. What should I do?</p> <hr> <p>Anyway, here is the code for a complete minimal example to reproduce the problem:</p> <pre class="lang-java prettyprint-override"><code>import org.eclipse.swt.SWT; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; public class TabTest { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); TabFolder tabFolder = new TabFolder (shell, SWT.NONE); TabItem item = new TabItem (tabFolder, SWT.NULL); item.setText ("Tab Item"); Composite comp = new Composite(tabFolder, SWT.NONE); comp.setLayout(new RowLayout()); item.setControl(comp); Button button = new Button(comp, SWT.PUSH); button.setText("Button "); tabFolder.setSize (160, 100); //Event Loop shell.pack (); shell.open (); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload