List of usage examples for org.eclipse.swt.widgets Composite setSize
public void setSize(int width, int height)
From source file:Snippet40.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Composite c1 = new Composite(shell, SWT.BORDER); c1.setSize(100, 100); Composite c2 = new Composite(shell, SWT.BORDER); c2.setBounds(100, 0, 100, 100);/*from w w w . j av a2s. co m*/ Menu menu = new Menu(shell, SWT.POP_UP); MenuItem item = new MenuItem(menu, SWT.PUSH); item.setText("Popup"); c1.setMenu(menu); c2.setMenu(menu); shell.setMenu(menu); shell.setSize(300, 300); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:PopupMenuAddTwoControls.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Composite c1 = new Composite(shell, SWT.BORDER); c1.setSize(100, 100); Composite c2 = new Composite(shell, SWT.BORDER); c2.setBounds(100, 0, 100, 100);/*from w w w. j ava 2 s .c o m*/ Menu menu = new Menu(shell, SWT.POP_UP); MenuItem item = new MenuItem(menu, SWT.PUSH); item.setText("Popup"); c1.setMenu(menu); c2.setMenu(menu); shell.setMenu(menu); shell.setSize(300, 300); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:CompositePaintListener.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display, SWT.SHELL_TRIM | SWT.H_SCROLL | SWT.V_SCROLL); final Composite composite = new Composite(shell, SWT.BORDER); composite.setSize(700, 600); final Color red = display.getSystemColor(SWT.COLOR_RED); composite.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { e.gc.setBackground(red);/*from www . j av a 2s .com*/ e.gc.fillOval(5, 5, 690, 590); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ScrollBarSelectionListener.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display, SWT.SHELL_TRIM | SWT.H_SCROLL | SWT.V_SCROLL); final Composite composite = new Composite(shell, SWT.BORDER); composite.setSize(700, 600); final Color red = display.getSystemColor(SWT.COLOR_RED); composite.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { e.gc.setBackground(red);//www . j a v a 2 s .c om e.gc.fillOval(5, 5, 690, 590); } }); final ScrollBar hBar = shell.getHorizontalBar(); hBar.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { System.out.println("ScrollBar selection listener"); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:Snippet9.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display, SWT.SHELL_TRIM | SWT.H_SCROLL | SWT.V_SCROLL); final Composite composite = new Composite(shell, SWT.BORDER); composite.setSize(200, 400); final ScrollBar hBar = shell.getHorizontalBar(); hBar.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { Point location = composite.getLocation(); location.x = -hBar.getSelection(); composite.setLocation(location); }// ww w . j a v a 2s .c o m }); final ScrollBar vBar = shell.getVerticalBar(); vBar.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { Point location = composite.getLocation(); location.y = -vBar.getSelection(); composite.setLocation(location); } }); shell.addListener(SWT.Resize, new Listener() { public void handleEvent(Event e) { Point size = composite.getSize(); Rectangle rect = shell.getClientArea(); hBar.setMaximum(size.x); vBar.setMaximum(size.y); hBar.setThumb(Math.min(size.x, rect.width)); vBar.setThumb(Math.min(size.y, rect.height)); int hPage = size.x - rect.width; int vPage = size.y - rect.height; int hSelection = hBar.getSelection(); int vSelection = vBar.getSelection(); Point location = composite.getLocation(); if (hSelection >= hPage) { if (hPage <= 0) hSelection = 0; location.x = -hSelection; } if (vSelection >= vPage) { if (vPage <= 0) vSelection = 0; location.y = -vSelection; } composite.setLocation(location); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet9.java
public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display, SWT.SHELL_TRIM | SWT.H_SCROLL | SWT.V_SCROLL); shell.setText("Snippet 9"); final Composite composite = new Composite(shell, SWT.BORDER); composite.setSize(700, 600); final Color red = display.getSystemColor(SWT.COLOR_RED); composite.addPaintListener(e -> { e.gc.setBackground(red);//w w w . j a va 2s . c om e.gc.fillOval(5, 5, 690, 590); }); final ScrollBar hBar = shell.getHorizontalBar(); hBar.addListener(SWT.Selection, e -> { Point location = composite.getLocation(); location.x = -hBar.getSelection(); composite.setLocation(location); }); final ScrollBar vBar = shell.getVerticalBar(); vBar.addListener(SWT.Selection, e -> { Point location = composite.getLocation(); location.y = -vBar.getSelection(); composite.setLocation(location); }); shell.addListener(SWT.Resize, e -> { Point size = composite.getSize(); Rectangle rect = shell.getClientArea(); hBar.setMaximum(size.x); vBar.setMaximum(size.y); hBar.setThumb(Math.min(size.x, rect.width)); vBar.setThumb(Math.min(size.y, rect.height)); int hPage = size.x - rect.width; int vPage = size.y - rect.height; int hSelection = hBar.getSelection(); int vSelection = vBar.getSelection(); Point location = composite.getLocation(); if (hSelection >= hPage) { if (hPage <= 0) hSelection = 0; location.x = -hSelection; } if (vSelection >= vPage) { if (vPage <= 0) vSelection = 0; location.y = -vSelection; } composite.setLocation(location); }); shell.setSize(600, 500); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:Snippet75.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); Composite c1 = new Composite(shell, SWT.BORDER); c1.setLayout(new RowLayout()); Button b1 = new Button(c1, SWT.PUSH); b1.setText("B1"); Button[] radios = new Button[3]; for (int i = 0; i < radios.length; i++) { radios[i] = new Button(c1, SWT.RADIO); radios[i].setText("R" + (i == 1 ? "&" : "") + i); }//from w w w .j a v a 2 s . c om Button b2 = new Button(c1, SWT.PUSH); b2.setText("B2"); List l1 = new List(c1, SWT.SINGLE | SWT.BORDER); l1.setItems(new String[] { "L1" }); Button b3 = new Button(c1, SWT.PUSH); b3.setText("B&3"); Button b3_1 = new Button(c1, SWT.PUSH); b3_1.setText("B3_1"); Composite c2 = new Composite(shell, SWT.BORDER); c2.setLayout(new RowLayout()); Button b4 = new Button(c2, SWT.PUSH); b4.setText("B&4"); Button b5 = new Button(c2, SWT.PUSH); b5.setText("B&5"); List l2 = new List(shell, SWT.SINGLE | SWT.BORDER); l2.setItems(new String[] { "L2" }); ToolBar tb1 = new ToolBar(shell, SWT.FLAT | SWT.BORDER); ToolItem i1 = new ToolItem(tb1, SWT.RADIO); i1.setText("I1"); ToolItem i2 = new ToolItem(tb1, SWT.RADIO); i2.setText("I&2"); Combo combo1 = new Combo(tb1, SWT.READ_ONLY | SWT.BORDER); combo1.setItems(new String[] { "C1" }); combo1.setText("C1"); combo1.pack(); ToolItem i3 = new ToolItem(tb1, SWT.SEPARATOR); i3.setWidth(combo1.getSize().x); i3.setControl(combo1); i3.setText("I3"); ToolItem i4 = new ToolItem(tb1, SWT.PUSH); i4.setText("I4"); ToolItem i5 = new ToolItem(tb1, SWT.CHECK); i5.setText("I5"); Button b6 = new Button(shell, SWT.PUSH); b6.setText("B&6"); Composite c4 = new Composite(shell, SWT.BORDER); c4.setSize(32, 32); Composite c5 = new Composite(c4, SWT.BORDER); c5.setSize(20, 20); Control[] list1 = new Control[] { b2, b1, b3_1, b3 }; c1.setTabList(list1); Control[] list2 = new Control[] { c1, b6, tb1, c4, c2, l2 }; shell.setTabList(list2); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:ScrollCompisiteHoriVertical.java
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("SashForm Test"); shell.setLayout(new FillLayout()); // Create the ScrolledComposite to scroll horizontally and vertically ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL); Composite child = new Composite(sc, SWT.NONE); child.setLayout(new FillLayout()); new Button(child, SWT.PUSH).setText("One"); new Button(child, SWT.PUSH).setText("Two"); child.setSize(400, 400); sc.setContent(child);/* w w w.j a va 2 s . c om*/ shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
From source file:WidgetWindow.java
protected Control createContents(Composite parent) { getShell().setText("Widget Window"); parent.setSize(400, 250); return parent; }
From source file:Ch4_Contributions.java
protected Control createContents(Composite parent) { getShell().setText("Action/Contribution Example"); parent.setSize(290, 150); aci.fill(parent);//from w ww . j av a 2 s . co m return parent; }