50 |
import javax.swing.event.TreeWillExpandListener; |
import javax.swing.event.TreeWillExpandListener; |
51 |
import javax.swing.plaf.TreeUI; |
import javax.swing.plaf.TreeUI; |
52 |
import javax.swing.tree.ExpandVetoException; |
import javax.swing.tree.ExpandVetoException; |
53 |
|
import javax.swing.tree.TreeCellRenderer; |
54 |
import javax.swing.tree.TreeModel; |
import javax.swing.tree.TreeModel; |
55 |
import javax.swing.tree.TreeNode; |
import javax.swing.tree.TreeNode; |
56 |
import javax.swing.tree.TreePath; |
import javax.swing.tree.TreePath; |
61 |
{ |
{ |
62 |
private static final long serialVersionUID = 7559816092864483649L; |
private static final long serialVersionUID = 7559816092864483649L; |
63 |
|
|
64 |
|
protected TreeCellRenderer cellRenderer; |
65 |
|
protected boolean editable; |
66 |
|
protected boolean rootVisible; |
67 |
|
protected boolean showsRootHandles; |
68 |
protected TreeModel treeModel; |
protected TreeModel treeModel; |
69 |
|
|
70 |
/** |
/** |
147 |
return null; |
return null; |
148 |
} |
} |
149 |
|
|
150 |
|
/** |
151 |
|
* Return the UI associated with this <code>JTree</code> object. |
152 |
|
* |
153 |
|
* @return the associated <code>TreeUI</code> object |
154 |
|
*/ |
155 |
public TreeUI getUI() |
public TreeUI getUI() |
156 |
{ |
{ |
157 |
return (TreeUI) ui; |
return (TreeUI) ui; |
158 |
} |
} |
159 |
|
|
160 |
|
/** |
161 |
|
* Sets the UI associated with this <code>JTree</code> object. |
162 |
|
* |
163 |
|
* @param ui the <code>TreeUI</code> to associate |
164 |
|
*/ |
165 |
public void setUI(TreeUI ui) |
public void setUI(TreeUI ui) |
166 |
{ |
{ |
167 |
super.setUI(ui); |
super.setUI(ui); |
168 |
} |
} |
169 |
|
|
170 |
|
/** |
171 |
|
* This method resets the UI used to the Look and Feel defaults.. |
172 |
|
*/ |
173 |
public void updateUI() |
public void updateUI() |
174 |
{ |
{ |
175 |
setUI((TreeUI) UIManager.getUI(this)); |
setUI((TreeUI) UIManager.getUI(this)); |
176 |
} |
} |
177 |
|
|
178 |
|
/** |
179 |
|
* This method returns the String ID of the UI class of Separator. |
180 |
|
* |
181 |
|
* @return The UI class' String ID. |
182 |
|
*/ |
183 |
public String getUIClassID() |
public String getUIClassID() |
184 |
{ |
{ |
185 |
return "TreeUI"; |
return "TreeUI"; |
186 |
} |
} |
187 |
|
|
188 |
|
/** |
189 |
|
* Gets the AccessibleContext associated with this <code>JToggleButton</code>. |
190 |
|
* |
191 |
|
* @return the associated context |
192 |
|
*/ |
193 |
public AccessibleContext getAccessibleContext() |
public AccessibleContext getAccessibleContext() |
194 |
{ |
{ |
195 |
return null; |
return null; |
196 |
} |
} |
197 |
|
|
198 |
|
/** |
199 |
|
* Returns the preferred viewport size.. |
200 |
|
* |
201 |
|
* @return the preferred size |
202 |
|
*/ |
203 |
public Dimension getPreferredScrollableViewportSize() |
public Dimension getPreferredScrollableViewportSize() |
204 |
{ |
{ |
205 |
return null; |
return null; |
387 |
for (int index = 0; index < listeners.length; ++index) |
for (int index = 0; index < listeners.length; ++index) |
388 |
listeners[index].treeWillExpand(event); |
listeners[index].treeWillExpand(event); |
389 |
} |
} |
390 |
|
|
391 |
|
/** |
392 |
|
* Returns the model of this <code>JTree</code> object. |
393 |
|
* |
394 |
|
* @return the associated <code>TreeModel</code> |
395 |
|
*/ |
396 |
|
public TreeModel getModel() |
397 |
|
{ |
398 |
|
return treeModel; |
399 |
|
} |
400 |
|
|
401 |
|
/** |
402 |
|
* Sets the model to use in <code>JTree</object>. |
403 |
|
* |
404 |
|
* @param model the <code>TreeModel</code> to use |
405 |
|
*/ |
406 |
|
public void setModel(TreeModel model) |
407 |
|
{ |
408 |
|
treeModel = model; |
409 |
|
} |
410 |
|
|
411 |
|
/** |
412 |
|
* Checks if this <code>JTree</code> object is editable. |
413 |
|
* |
414 |
|
* @return <code>true</code> if this tree object is editable, |
415 |
|
* <code>false</code> otherwise |
416 |
|
*/ |
417 |
|
public boolean isEditable() |
418 |
|
{ |
419 |
|
return editable; |
420 |
|
} |
421 |
|
|
422 |
|
/** |
423 |
|
* Sets the <code>editable</code> property. |
424 |
|
* |
425 |
|
* @param flag <code>true</code> to make this tree object editable, |
426 |
|
* <code>false</code> otherwise |
427 |
|
*/ |
428 |
|
public void setEditable(boolean flag) |
429 |
|
{ |
430 |
|
if (editable == flag) |
431 |
|
return; |
432 |
|
|
433 |
|
boolean oldValue = editable; |
434 |
|
editable = flag; |
435 |
|
firePropertyChange("editable", oldValue, editable); |
436 |
|
} |
437 |
|
|
438 |
|
/** |
439 |
|
* Checks if the root element is visible. |
440 |
|
* |
441 |
|
* @return <code>true</code> if the root element is visible, |
442 |
|
* <code>false</code> otherwise |
443 |
|
*/ |
444 |
|
public boolean isRootVisbile() |
445 |
|
{ |
446 |
|
return rootVisible; |
447 |
|
} |
448 |
|
|
449 |
|
public void setRootVisible(boolean flag) |
450 |
|
{ |
451 |
|
rootVisible = flag; |
452 |
|
} |
453 |
|
|
454 |
|
public boolean getShowsRootHandles() |
455 |
|
{ |
456 |
|
return showsRootHandles; |
457 |
|
} |
458 |
|
|
459 |
|
public void setShowRootHandles(boolean flag) |
460 |
|
{ |
461 |
|
showsRootHandles = flag; |
462 |
|
} |
463 |
|
|
464 |
|
public TreeCellRenderer getCellRenderer() |
465 |
|
{ |
466 |
|
return cellRenderer; |
467 |
|
} |
468 |
|
|
469 |
|
public void setCellRenderer(TreeCellRenderer newRenderer) |
470 |
|
{ |
471 |
|
cellRenderer = newRenderer; |
472 |
|
} |
473 |
} |
} |