-getParentWidget getChildren addChild removeChild removeFromParent addChildren removeChildren bringToFront bringToBack
- | Methods for manipulation with the tree hierarchy of widgets.
+ | getParentWidget getChildren addChild removeChild removeFromParent addChildren removeChildren bringToFront bringToBack orderChildren
+ | Methods for manipulation with the tree hierarchy of widgets. The Widget.orderChildren allows to change order of children. Additional tree-manipulation methods are available in WidgetSupport .
|
getChildConstraint setChildConstraint
| Controls constraints assigned to child widgets. Used by Layouts similarly to Swing. See Layout section.
Index: graph/lib/test/unit/src/apichanges/WidgetOrderTest.java
===================================================================
RCS file: graph/lib/test/unit/src/apichanges/WidgetOrderTest.java
diff -N graph/lib/test/unit/src/apichanges/WidgetOrderTest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ graph/lib/test/unit/src/apichanges/WidgetOrderTest.java 7 Jan 2008 15:17:15 -0000
@@ -0,0 +1,92 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * The Original Software is NetBeans. The Initial Developer of the Original
+ * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
+ * Microsystems, Inc. All Rights Reserved.
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ */
+package apichanges;
+
+import org.netbeans.api.visual.widget.LabelWidget;
+import org.netbeans.api.visual.widget.Scene;
+import org.netbeans.api.visual.widget.Widget;
+import org.netbeans.api.visual.widget.WidgetSupport;
+import org.netbeans.junit.NbTestCase;
+
+import java.util.Arrays;
+
+/**
+ * Test for #121525 - Widget.orderChildren
+ * @author David Kaspar
+ */
+public class WidgetOrderTest extends NbTestCase {
+
+ public WidgetOrderTest (String testName) {
+ super (testName);
+ }
+
+ public void testOrder () {
+ Scene scene = new Scene ();
+
+ LabelWidget label0 = new LabelWidget (scene, "0");
+ scene.addChild (label0);
+ LabelWidget label1 = new LabelWidget (scene, "1");
+ scene.addChild (label1);
+ LabelWidget label2 = new LabelWidget (scene, "2");
+ scene.addChild (label2);
+ LabelWidget label3 = new LabelWidget (scene, "3");
+ scene.addChild (label3);
+
+ scene.orderChildren (Arrays.asList (2, 3, 0, 1));
+ assertEquals ("2,3,0,1,", dumpOrder (scene));
+
+ WidgetSupport.bringForward (label0);
+ assertEquals ("2,3,1,0,", dumpOrder (scene));
+
+ WidgetSupport.bringBackward (label3);
+ assertEquals ("3,2,1,0,", dumpOrder (scene));
+ }
+
+ private static String dumpOrder (Scene scene) {
+ StringBuffer buffer = new StringBuffer ();
+ for (Widget child : scene.getChildren ()) {
+ LabelWidget label = (LabelWidget) child;
+ buffer.append (label.getLabel ()).append (',');
+ }
+ return buffer.toString ();
+ }
+
+}
|