Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 9876912ed4f98f998295d7c2d829080655a501ff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*******************************************************************************
 * Copyright (c) 2018 Red Hat and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     Red Hat - initial API and implementation
 *******************************************************************************/
package org.eclipse.swt.tests.gtk.snippets;


import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;

public class Bug147320_ShellSetBounds {

	
		static final Rectangle[] DIMENSIONS = {
			new Rectangle (520, 367, 240, 290),
			new Rectangle (520, 320, 240, 320),
			new Rectangle (320, 272, 640, 480),
			new Rectangle (240, 212, 800, 600)};
		static int counter = 0;
		public static void main(String[] args) {
		    Display display = new Display();
		    final Shell shell = new Shell(display, SWT.NONE);
		    Button button = new Button(shell, SWT.PUSH);
		    button.setBounds(10,10,50,30);
		    button.setText("Push");
		    button.addListener(SWT.Selection, new Listener() {
				@Override
				public void handleEvent(Event event) {
					Rectangle bounds = DIMENSIONS[counter++];
					if (counter == 4) counter = 0;
					System.out.println("setting to: " + bounds);
					shell.setBounds(bounds);
				}
			});
		    shell.setBounds(DIMENSIONS[counter++]);
		    shell.open();
		    while (!shell.isDisposed()) {
		        if (!display.readAndDispatch()) display.sleep();
		    }
		    display.dispose();
		}
}

Back to the top