|
| 1 | +/******************************************************************************* |
| 2 | + * Java2Script Pacemaker (http://j2s.sourceforge.net) |
| 3 | + * |
| 4 | + * Copyright (c) 2006 ognize.com and others. |
| 5 | + * All rights reserved. This program and the accompanying materials |
| 6 | + * are made available under the terms of the Eclipse Public License v1.0 |
| 7 | + * which accompanies this distribution, and is available at |
| 8 | + * http://www.eclipse.org/legal/epl-v10.html |
| 9 | + * |
| 10 | + * Contributors: |
| 11 | + * ognize.com - initial API and implementation |
| 12 | + *******************************************************************************/ |
| 13 | + |
| 14 | +package net.sf.j2s.test.swt.widgets; |
| 15 | + |
| 16 | +import org.eclipse.swt.SWT; |
| 17 | +import org.eclipse.swt.events.ControlEvent; |
| 18 | +import org.eclipse.swt.events.ControlListener; |
| 19 | +import org.eclipse.swt.graphics.Point; |
| 20 | +import org.eclipse.swt.widgets.Display; |
| 21 | +import org.eclipse.swt.widgets.Shell; |
| 22 | + |
| 23 | +/** |
| 24 | + * @author josson smith |
| 25 | + * |
| 26 | + * 2006-10-16 |
| 27 | + */ |
| 28 | +public class TestNestedShells { |
| 29 | + /** |
| 30 | + * @param args |
| 31 | + */ |
| 32 | + public static void main(String[] args) { |
| 33 | + Display display = new Display (); |
| 34 | + final Shell shell = new Shell (display); |
| 35 | + shell.setText ("hi"); |
| 36 | + shell.setSize(210, 120); |
| 37 | + shell.open (); |
| 38 | + final Shell shell2 = new Shell(shell); |
| 39 | + shell2.setSize(110, 60); |
| 40 | + shell2.open(); |
| 41 | + shell.addControlListener(new ControlListener() { |
| 42 | + int lastX, lastY; |
| 43 | + public void controlResized(ControlEvent e) { |
| 44 | + // TODO Auto-generated method stub |
| 45 | + } |
| 46 | + public void controlMoved(ControlEvent e) { |
| 47 | + Point pt = shell.getLocation(); |
| 48 | + Point pt2 = shell2.getLocation(); |
| 49 | + shell2.setLocation(pt2.x + pt.x - lastX, pt2.y + pt.y - lastY); |
| 50 | + lastX = pt.x; |
| 51 | + lastY = pt.y; |
| 52 | + } |
| 53 | + }); |
| 54 | + while (!shell.isDisposed()) { |
| 55 | + if (!display.readAndDispatch ()) display.sleep (); |
| 56 | + } |
| 57 | + display.dispose (); |
| 58 | + } |
| 59 | +} |
0 commit comments