2176 */
2177 public int getIndex(TreeNode node) {
2178 for(int counter = getChildCount() - 1; counter >= 0; counter--)
2179 if(getChildAt(counter) == node)
2180 return counter;
2181 return -1;
2182 }
2183
2184 /**
2185 * Returns true if the receiver allows children.
2186 * @return true if the receiver allows children, otherwise false
2187 */
2188 public abstract boolean getAllowsChildren();
2189
2190
2191 /**
2192 * Returns the children of the receiver as an
2193 * <code>Enumeration</code>.
2194 * @return the children of the receiver as an <code>Enumeration</code>
2195 */
2196 public abstract Enumeration<?> children();
2197
2198
2199 // --- serialization ---------------------------------------------
2200
2201 private void writeObject(ObjectOutputStream s) throws IOException {
2202 s.defaultWriteObject();
2203 StyleContext.writeAttributeSet(s, attributes);
2204 }
2205
2206 private void readObject(ObjectInputStream s)
2207 throws ClassNotFoundException, IOException
2208 {
2209 s.defaultReadObject();
2210 MutableAttributeSet attr = new SimpleAttributeSet();
2211 StyleContext.readAttributeSet(s, attr);
2212 AttributeContext context = getAttributeContext();
2213 attributes = context.addAttributes(SimpleAttributeSet.EMPTY, attr);
2214 }
2215
2216 // ---- variables -----------------------------------------------------
2439 return false;
2440 }
2441
2442
2443 // ------ TreeNode ----------------------------------------------
2444
2445 /**
2446 * Returns true if the receiver allows children.
2447 * @return true if the receiver allows children, otherwise false
2448 */
2449 public boolean getAllowsChildren() {
2450 return true;
2451 }
2452
2453
2454 /**
2455 * Returns the children of the receiver as an
2456 * <code>Enumeration</code>.
2457 * @return the children of the receiver
2458 */
2459 public Enumeration<AbstractElement> children() {
2460 if(nchildren == 0)
2461 return null;
2462
2463 Vector<AbstractElement> tempVector = new Vector<AbstractElement>(nchildren);
2464
2465 for(int counter = 0; counter < nchildren; counter++)
2466 tempVector.addElement(children[counter]);
2467 return tempVector.elements();
2468 }
2469
2470 // ------ members ----------------------------------------------
2471
2472 private AbstractElement[] children;
2473 private int nchildren;
2474 private int lastIndex;
2475 }
2476
2477 /**
2478 * Implements an element that directly represents content of
2479 * some kind.
2480 * <p>
2481 * <strong>Warning:</strong>
2482 * Serialized objects of this class will not be compatible with
2483 * future Swing releases. The current serialization support is
2593 public boolean isLeaf() {
2594 return true;
2595 }
2596
2597 // ------ TreeNode ----------------------------------------------
2598
2599 /**
2600 * Returns true if the receiver allows children.
2601 * @return true if the receiver allows children, otherwise false
2602 */
2603 public boolean getAllowsChildren() {
2604 return false;
2605 }
2606
2607
2608 /**
2609 * Returns the children of the receiver as an
2610 * <code>Enumeration</code>.
2611 * @return the children of the receiver
2612 */
2613 public Enumeration<?> children() {
2614 return null;
2615 }
2616
2617 // --- serialization ---------------------------------------------
2618
2619 private void writeObject(ObjectOutputStream s) throws IOException {
2620 s.defaultWriteObject();
2621 s.writeInt(p0.getOffset());
2622 s.writeInt(p1.getOffset());
2623 }
2624
2625 private void readObject(ObjectInputStream s)
2626 throws ClassNotFoundException, IOException
2627 {
2628 s.defaultReadObject();
2629
2630 // set the range with positions that track change
2631 int off0 = s.readInt();
2632 int off1 = s.readInt();
2633 try {
|
2176 */
2177 public int getIndex(TreeNode node) {
2178 for(int counter = getChildCount() - 1; counter >= 0; counter--)
2179 if(getChildAt(counter) == node)
2180 return counter;
2181 return -1;
2182 }
2183
2184 /**
2185 * Returns true if the receiver allows children.
2186 * @return true if the receiver allows children, otherwise false
2187 */
2188 public abstract boolean getAllowsChildren();
2189
2190
2191 /**
2192 * Returns the children of the receiver as an
2193 * <code>Enumeration</code>.
2194 * @return the children of the receiver as an <code>Enumeration</code>
2195 */
2196 public abstract Enumeration<TreeNode> children();
2197
2198
2199 // --- serialization ---------------------------------------------
2200
2201 private void writeObject(ObjectOutputStream s) throws IOException {
2202 s.defaultWriteObject();
2203 StyleContext.writeAttributeSet(s, attributes);
2204 }
2205
2206 private void readObject(ObjectInputStream s)
2207 throws ClassNotFoundException, IOException
2208 {
2209 s.defaultReadObject();
2210 MutableAttributeSet attr = new SimpleAttributeSet();
2211 StyleContext.readAttributeSet(s, attr);
2212 AttributeContext context = getAttributeContext();
2213 attributes = context.addAttributes(SimpleAttributeSet.EMPTY, attr);
2214 }
2215
2216 // ---- variables -----------------------------------------------------
2439 return false;
2440 }
2441
2442
2443 // ------ TreeNode ----------------------------------------------
2444
2445 /**
2446 * Returns true if the receiver allows children.
2447 * @return true if the receiver allows children, otherwise false
2448 */
2449 public boolean getAllowsChildren() {
2450 return true;
2451 }
2452
2453
2454 /**
2455 * Returns the children of the receiver as an
2456 * <code>Enumeration</code>.
2457 * @return the children of the receiver
2458 */
2459 public Enumeration<TreeNode> children() {
2460 if(nchildren == 0)
2461 return null;
2462
2463 Vector<TreeNode> tempVector = new Vector<>(nchildren);
2464
2465 for(int counter = 0; counter < nchildren; counter++)
2466 tempVector.addElement(children[counter]);
2467 return tempVector.elements();
2468 }
2469
2470 // ------ members ----------------------------------------------
2471
2472 private AbstractElement[] children;
2473 private int nchildren;
2474 private int lastIndex;
2475 }
2476
2477 /**
2478 * Implements an element that directly represents content of
2479 * some kind.
2480 * <p>
2481 * <strong>Warning:</strong>
2482 * Serialized objects of this class will not be compatible with
2483 * future Swing releases. The current serialization support is
2593 public boolean isLeaf() {
2594 return true;
2595 }
2596
2597 // ------ TreeNode ----------------------------------------------
2598
2599 /**
2600 * Returns true if the receiver allows children.
2601 * @return true if the receiver allows children, otherwise false
2602 */
2603 public boolean getAllowsChildren() {
2604 return false;
2605 }
2606
2607
2608 /**
2609 * Returns the children of the receiver as an
2610 * <code>Enumeration</code>.
2611 * @return the children of the receiver
2612 */
2613 @Override
2614 public Enumeration<TreeNode> children() {
2615 return null;
2616 }
2617
2618 // --- serialization ---------------------------------------------
2619
2620 private void writeObject(ObjectOutputStream s) throws IOException {
2621 s.defaultWriteObject();
2622 s.writeInt(p0.getOffset());
2623 s.writeInt(p1.getOffset());
2624 }
2625
2626 private void readObject(ObjectInputStream s)
2627 throws ClassNotFoundException, IOException
2628 {
2629 s.defaultReadObject();
2630
2631 // set the range with positions that track change
2632 int off0 = s.readInt();
2633 int off1 = s.readInt();
2634 try {
|