blob: 66c384dd897959ac9cf9c952f94d3b1010afe2e0 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2018 Red Hat and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* 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();
}
}