1/* 2 * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24/* 25 * @test 26 * @bug 6402062 6487891 27 * @summary Tests JTree encoding 28 * @author Sergey Malenkov 29 */ 30 31import javax.swing.JTree; 32import javax.swing.event.TreeModelListener; 33import javax.swing.tree.TreeModel; 34import javax.swing.tree.TreePath; 35 36public final class javax_swing_JTree extends AbstractTest<JTree> { 37 public static void main(String[] args) { 38 new javax_swing_JTree().test(true); 39 } 40 41 protected JTree getObject() { 42 return new JTree(new MyModel()); 43 } 44 45 protected JTree getAnotherObject() { 46 return new JTree(); 47 } 48 49 protected void validate(JTree before, JTree after) { 50 Class type = after.getModel().getClass(); 51 if (!type.equals(before.getModel().getClass())) 52 throw new Error("Invalid model: " + type); 53 } 54 55 public static final class MyModel implements TreeModel { 56 public Object getRoot() { 57 return null; 58 } 59 60 public Object getChild(Object parent, int index) { 61 return null; 62 } 63 64 public int getChildCount(Object parent) { 65 return 0; 66 } 67 68 public boolean isLeaf(Object node) { 69 return false; 70 } 71 72 public void valueForPathChanged(TreePath path, Object newValue) { 73 } 74 75 public int getIndexOfChild(Object parent, Object child) { 76 return 0; 77 } 78 79 public void addTreeModelListener(TreeModelListener listener) { 80 } 81 82 public void removeTreeModelListener(TreeModelListener listener) { 83 } 84 } 85} 86