CoolItem Unable to take entire space horizontally [message #449460] |
Mon, 24 January 2005 21:08 |
S Dix Messages: 43 Registered: July 2009 |
Member |
|
|
Hi,
I am trying to add one single button in the coolbar, but somehow it does
not take un the entire space horizontally. There is some gap on both sides
of the button. I am attaching a sample wherein I am adding a coolbar
setting the coolbars backgroud color and adding a button. You will clearly
see the red color on both sides of the button.
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.*;
public class MySnippet20 {
public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
FillLayout fillLayout = new FillLayout();
fillLayout.type = SWT.HORIZONTAL;
shell.setLayout(fillLayout);
CoolBar bar = new CoolBar (shell, SWT.NONE);
bar.setBackground(display.getSystemColor (SWT.COLOR_RED));
CoolItem item = new CoolItem (bar, SWT.NONE);
Button button = new Button (bar, SWT.PUSH);
button.setText ("Button 0");
Point size = button.computeSize (SWT.DEFAULT, SWT.DEFAULT);
item.setPreferredSize (item.computeSize (size.x, size.y));
item.setControl (button);
bar.pack ();
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
Any help is appreciated.
|
|
|
Powered by
FUDForum. Page generated in 0.03427 seconds