SashForm: getMaximizedControl() : SashForm « org.eclipse.swt.custom « Java by API






SashForm: getMaximizedControl()

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class MainClass {

  public static void main(String[] a) {
    
    final Display d = new Display();
    final Shell shell = new Shell(d);

    shell.setSize(250, 200);
    
    shell.setLayout(new GridLayout(1, false));

    Composite sash = new Composite(shell, SWT.NONE);
    sash.setLayout(new FillLayout());
    sash.setLayoutData(new GridData(GridData.FILL_BOTH));
    final SashForm sashForm = new SashForm(sash, SWT.HORIZONTAL);

    sashForm.SASH_WIDTH = 5;

    sashForm.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_WHITE));

    final Button one = new Button(sashForm, SWT.PUSH);
    one.setText("One");
    one.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        maximizeHelper(one, sashForm);
      }
    });

    final Button two = new Button(sashForm, SWT.PUSH);
    two.setText("Two");
    two.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        maximizeHelper(two, sashForm);
      }
    });

    final Button three = new Button(sashForm, SWT.PUSH);
    three.setText("Three");
    three.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        maximizeHelper(three, sashForm);
      }
    });

    shell.open();
    while (!shell.isDisposed()) {
      if (!d.readAndDispatch())
        d.sleep();
    }
    d.dispose();
  }
  private static void maximizeHelper(Control control, SashForm sashForm) {
    // See if the control is already maximized
    if (control == sashForm.getMaximizedControl()) {
      // Already maximized; restore it
      sashForm.setMaximizedControl(null);
    } else {
      // Not yet maximized, so maximize it
      sashForm.setMaximizedControl(control);
    }
  }

}



           
       








Related examples in the same category

1.SashForm: SASH_WIDTH
2.SashForm: setMaximizedControl(Control control)
3.SashForm: setBackground(Color color)
4.SashForm: setOrientation(int o)
5.SashForm: setWeights(int[] arg0)