|
|
|
|
Re: SashForm children width [message #649987 is a reply to message #648333] |
Fri, 21 January 2011 10:07 |
Michael Messages: 4 Registered: October 2010 |
Junior Member |
|
|
Quote: | Which platform are you using? Can you paste an example snippet showing your problem?
|
I'm using Linux/GTK, although this should work on other platforms (win32 and macosx). Here's the snippet:
public class SashExample {
public static void main(String[] args) {
final int MIN_SIZE = 150;
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
final SashForm sashForm = new SashForm(shell, SWT.NONE);
final Composite left = new Composite(sashForm, SWT.BORDER);
final Composite right = new Composite(sashForm, SWT.BORDER);
left.setLayout(new RowLayout());
right.setLayout(new RowLayout());
new Label(left, SWT.NONE).setText("Left side");
new Label(right, SWT.NONE).setText("Right side");
left.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent event) {
if (left.getBounds().width < MIN_SIZE) {
int totalWidth = sashForm.getClientArea().width;
sashForm.setWeights(new int[] {MIN_SIZE, totalWidth - MIN_SIZE});
}
}
});
sashForm.setWeights(new int [] {1, 3});
shell.setSize(1000, 600);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
Thanks!
|
|
|
|
Powered by
FUDForum. Page generated in 0.03696 seconds