Method from javax.swing.JTree$AccessibleJTree Detail: |
public void addAccessibleSelection(int i) {
TreeModel model = JTree.this.getModel();
if (model != null) {
if (i == 0) {
Object[] objPath = {model.getRoot()};
TreePath path = new TreePath(objPath);
JTree.this.addSelectionPath(path);
}
}
}
Adds the specified selected item in the object to the object's
selection. If the object supports multiple selections,
the specified item is added to any existing selection, otherwise
it replaces any existing selection in the object. If the
specified item is already selected, this method has no effect. |
public void clearAccessibleSelection() {
int childCount = getAccessibleChildrenCount();
for (int i = 0; i < childCount; i++) {
removeAccessibleSelection(i);
}
}
Clears the selection in the object, so that nothing in the
object is selected. |
public void fireVisibleDataPropertyChange() {
firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
Boolean.valueOf(false), Boolean.valueOf(true));
}
Fire a visible data property change notification.
A 'visible' data property is one that represents
something about the way the component appears on the
display, where that appearance isn't bound to any other
property. It notifies screen readers that the visual
appearance of the component has changed, so they can
notify the user. |
public Accessible getAccessibleAt(Point p) {
TreePath path = getClosestPathForLocation(p.x, p.y);
if (path != null) {
// JTree.this is NOT the parent; parent will get computed later
return new AccessibleJTreeNode(JTree.this, path, null);
} else {
return null;
}
}
Returns the Accessible child, if one exists,
contained at the local coordinate Point .
Otherwise returns null . |
public Accessible getAccessibleChild(int i) {
TreeModel model = JTree.this.getModel();
if (model == null) {
return null;
}
if (isRootVisible()) {
if (i == 0) { // return the root node Accessible
Object[] objPath = { model.getRoot() };
TreePath path = new TreePath(objPath);
return new AccessibleJTreeNode(JTree.this, path, JTree.this);
} else {
return null;
}
}
// return Accessible for one of root's child nodes
int count = model.getChildCount(model.getRoot());
if (i < 0 || i >= count) {
return null;
}
Object obj = model.getChild(model.getRoot(), i);
Object[] objPath = { model.getRoot(), obj };
TreePath path = new TreePath(objPath);
return new AccessibleJTreeNode(JTree.this, path, JTree.this);
}
Return the nth Accessible child of the object. |
public int getAccessibleChildrenCount() {
TreeModel model = JTree.this.getModel();
if (model == null) {
return 0;
}
if (isRootVisible()) {
return 1; // the root node
}
// return the root's first set of children count
return model.getChildCount(model.getRoot());
}
Returns the number of top-level children nodes of this
JTree. Each of these nodes may in turn have children nodes. |
public int getAccessibleIndexInParent() {
// didn't ever need to override this...
return super.getAccessibleIndexInParent();
}
Get the index of this object in its accessible parent. |
public AccessibleRole getAccessibleRole() {
return AccessibleRole.TREE;
}
Get the role of this object. |
public AccessibleSelection getAccessibleSelection() {
return this;
}
Get the AccessibleSelection associated with this object. In the
implementation of the Java Accessibility API for this class,
return this object, which is responsible for implementing the
AccessibleSelection interface on behalf of itself. |
public Accessible getAccessibleSelection(int i) {
// The JTree can have only one accessible child, the root.
if (i == 0) {
Object[] rootPath = new Object[1];
rootPath[0] = treeModel.getRoot();
TreePath childPath = new TreePath(rootPath);
if (JTree.this.isPathSelected(childPath)) {
return new AccessibleJTreeNode(JTree.this, childPath, JTree.this);
}
}
return null;
}
Returns an Accessible representing the specified selected item
in the object. If there isn't a selection, or there are
fewer items selected than the integer passed in, the return
value will be null. |
public int getAccessibleSelectionCount() {
Object[] rootPath = new Object[1];
rootPath[0] = treeModel.getRoot();
TreePath childPath = new TreePath(rootPath);
if (JTree.this.isPathSelected(childPath)) {
return 1;
} else {
return 0;
}
}
Returns the number of items currently selected.
If no items are selected, the return value will be 0. |
public boolean isAccessibleChildSelected(int i) {
// The JTree can have only one accessible child, the root.
if (i == 0) {
Object[] rootPath = new Object[1];
rootPath[0] = treeModel.getRoot();
TreePath childPath = new TreePath(rootPath);
return JTree.this.isPathSelected(childPath);
} else {
return false;
}
}
Returns true if the current child of this object is selected. |
public void removeAccessibleSelection(int i) {
TreeModel model = JTree.this.getModel();
if (model != null) {
if (i == 0) {
Object[] objPath = {model.getRoot()};
TreePath path = new TreePath(objPath);
JTree.this.removeSelectionPath(path);
}
}
}
Removes the specified selected item in the object from the object's
selection. If the specified item isn't currently selected, this
method has no effect. |
public void selectAllAccessibleSelection() {
TreeModel model = JTree.this.getModel();
if (model != null) {
Object[] objPath = {model.getRoot()};
TreePath path = new TreePath(objPath);
JTree.this.addSelectionPath(path);
}
}
Causes every selected item in the object to be selected
if the object supports multiple selections. |
public void treeCollapsed(TreeExpansionEvent e) {
fireVisibleDataPropertyChange();
TreePath path = e.getPath();
if (path != null) {
// Set parent to null so AccessibleJTreeNode computes
// its parent.
AccessibleJTreeNode node = new AccessibleJTreeNode(JTree.this,
path,
null);
PropertyChangeEvent pce = new PropertyChangeEvent(node,
AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
AccessibleState.EXPANDED,
AccessibleState.COLLAPSED);
firePropertyChange(AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
null, pce);
}
}
Tree Collapsed notification. |
public void treeExpanded(TreeExpansionEvent e) {
fireVisibleDataPropertyChange();
TreePath path = e.getPath();
if (path != null) {
// TIGER - 4839971
// Set parent to null so AccessibleJTreeNode computes
// its parent.
AccessibleJTreeNode node = new AccessibleJTreeNode(JTree.this,
path,
null);
PropertyChangeEvent pce = new PropertyChangeEvent(node,
AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
AccessibleState.COLLAPSED,
AccessibleState.EXPANDED);
firePropertyChange(AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
null, pce);
}
}
Tree Model Expansion notification. |
public void treeNodesChanged(TreeModelEvent e) {
fireVisibleDataPropertyChange();
}
Tree Model Node change notification. |
public void treeNodesInserted(TreeModelEvent e) {
fireVisibleDataPropertyChange();
}
Tree Model Node change notification. |
public void treeNodesRemoved(TreeModelEvent e) {
fireVisibleDataPropertyChange();
}
Tree Model Node change notification. |
public void treeStructureChanged(TreeModelEvent e) {
fireVisibleDataPropertyChange();
}
Tree Model structure change change notification. |
public void valueChanged(TreeSelectionEvent e) {
// Fixes 4546503 - JTree is sending incorrect active
// descendant events
TreePath oldLeadSelectionPath = e.getOldLeadSelectionPath();
leadSelectionPath = e.getNewLeadSelectionPath();
if (oldLeadSelectionPath != leadSelectionPath) {
// Set parent to null so AccessibleJTreeNode computes
// its parent.
Accessible oldLSA = leadSelectionAccessible;
leadSelectionAccessible = (leadSelectionPath != null)
? new AccessibleJTreeNode(JTree.this,
leadSelectionPath,
null) // parent
: null;
firePropertyChange(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
oldLSA, leadSelectionAccessible);
}
firePropertyChange(AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY,
Boolean.valueOf(false), Boolean.valueOf(true));
}
Tree Selection Listener value change method. Used to fire the
property change |