Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » CoolItem Unable to take entire space horizontally
CoolItem Unable to take entire space horizontally [message #449460] Mon, 24 January 2005 21:08
S Dix is currently offline S DixFriend
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.
Previous Topic:New Platform Browser from Browser Widget
Next Topic:JFace App - how to handle close event?
Goto Forum:
  


Current Time: Thu Apr 25 04:50:08 GMT 2024

Powered by FUDForum. Page generated in 0.03427 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top