Java Tutorial/SWT/Decorations

Материал из Java эксперт
Версия от 15:20, 31 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

17. Decorations Styles

ConstantDescriptionSWT.BORDERCreates a window with a nonresizable border.SWT.CLOSECreates a window that can be closed.SWT.MINCreates a window that can be minimized.SWT.MAXCreates a window that can be maximized.SWT.NO_TRIMCreates a window with no border, title bar, or any other kind of trim.SWT.RESIZECreates a window with a resizable border.SWT.TITLECreates a window with a title bar.SWT.ON_TOPCreates a window at the top of the z-order within the parent composite.SWT.TOOLCreates a window with a thin tool border.SWT.SHELL_TRIMConvenience constant that combines SWT.CLOSE, SWT.TITLE, SWT.MIN, SWT.MAX, and SWT.RESIZE.SWT.DIALOG_TRIMConvenience constant that combines SWT.CLOSE, SWT.TITLE, and SWT.BORDER.


17. Displays nine Decorations objects, one for each distinct style.

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Decorations;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
public class DecroationStyles {
  public static void main(String[] args) {
    Display display = new Display();
    Shell composite = new Shell(display);
    composite.setText("Decorations Example");
    composite.setLayout(new GridLayout(3, true));
    // The SWT.BORDER style
    Decorations d = new Decorations(composite, SWT.BORDER);
//    d = new Decorations(composite, SWT.CLOSE);
//    d = new Decorations(composite, SWT.MIN);
//    d = new Decorations(composite, SWT.MAX);
//    d = new Decorations(composite, SWT.NO_TRIM);
//    d = new Decorations(composite, SWT.RESIZE);
//    d = new Decorations(composite, SWT.TITLE);
//    d = new Decorations(composite, SWT.ON_TOP);
//   d = new Decorations(composite, SWT.TOOL);
    
    d.setLayoutData(new GridData(GridData.FILL_BOTH));
    d.setLayout(new FillLayout());
    new Label(d, SWT.CENTER).setText("SWT.BORDER");
    composite.open();
    while (!composite.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    display.dispose();
  }
}