📄 jtree.java
字号:
* * @return the font for the current node */ public Font getFont() { return tree.getFont(); } /** * Gets the FontMetrics of this object. * * @param f - the current font. * @return the font metrics for the given font. */ public FontMetrics getFontMetrics(Font f) { return tree.getFontMetrics(f); } /** * Get the foreground color of this object. * * @return the foreground for this object. */ public Color getForeground() { return tree.getForeground(); } /** * Gets the locale of the component. * * @return the locale of the component. */ public Locale getLocale() { return tree.getLocale(); } /** * Gets the location of the object relative to the * parent in the form of a point specifying the object's * top-left corner in the screen's coordinate space. * * @return the location of the current node. */ public Point getLocation() { return getLocationInJTree(); } /** * Returns the location in the tree. * * @return the location in the JTree. */ protected Point getLocationInJTree() { Rectangle bounds = tree.getPathBounds(tp); return new Point(bounds.x, bounds.y); } /** * Returns the location of the object on the screen. * * @return the location of the object on the screen. */ public Point getLocationOnScreen() { Point loc = getLocation(); SwingUtilities.convertPointToScreen(loc, tree); return loc; } /** * Returns the size of this object in the form of a Dimension object. * * @return the size of the object */ public Dimension getSize() { Rectangle b = getBounds(); return b.getSize(); } /** * Returns true if the current child of this object is selected. * * @param i - the child of the current node * @return true if the child is selected. */ public boolean isAccessibleChildSelected(int i) { Object child = mod.getChild(tp.getLastPathComponent(), i); if (child != null) return tree.isPathSelected(tp.pathByAddingChild(child)); return false; } /** * Determines if the object is enabled. * * @return true if the tree is enabled */ public boolean isEnabled() { return tree.isEnabled(); } /** * Returns whether this object can accept focus or not. * * @return true, it is always focus traversable */ public boolean isFocusTraversable() { return true; } /** * Determines if the object is showing. * * @return true if the object is visible and the * parent is visible. */ public boolean isShowing() { return isVisible() && tree.isShowing(); } /** * Determines if the object is visible. * * @return true if the object is visible. */ public boolean isVisible() { return tree.isVisible(tp); } /** * Removes the specified selected item in the object from the * object's selection. * * @param i - the specified item to remove */ public void removeAccessibleSelection(int i) { if (mod != null) { Object child = mod.getChild(tp.getLastPathComponent(), i); if (child != null) { if (!states.contains(AccessibleState.MULTISELECTABLE)) clearAccessibleSelection(); if (selectionList.contains(child)) { selectionList.remove(child); tree.removeSelectionPath(tp.pathByAddingChild(child)); } } } } /** * Removes the specified focus listener so it no longer receives focus * events from this component. * * @param l - the focus listener to remove */ public void removeFocusListener(FocusListener l) { tree.removeFocusListener(l); } /** * Remove a PropertyChangeListener from the listener list. * * @param l - the property change listener to remove. */ public void removePropertyChangeListener(PropertyChangeListener l) { // Nothing to do here. } /** * Requests focus for this object. */ public void requestFocus() { tree.requestFocus(); } /** * Causes every selected item in the object to be selected if the object * supports multiple selections. */ public void selectAllAccessibleSelection() { Object parent = tp.getLastPathComponent(); if (mod != null) { for (int i = 0; i < mod.getChildCount(parent); i++) { Object child = mod.getChild(parent, i); if (child != null) { if (!states.contains(AccessibleState.MULTISELECTABLE)) clearAccessibleSelection(); if (selectionList.contains(child)) { selectionList.add(child); tree.addSelectionPath(tp.pathByAddingChild(child)); } } } } } /** * Set the accessible description of this object. * * @param s - the string to set the accessible description to. */ public void setAccessibleDescription(String s) { super.setAccessibleDescription(s); } /** * Set the localized accessible name of this object. * * @param s - the string to set the accessible name to. */ public void setAccessibleName(String s) { super.setAccessibleName(s); } /** * Set the background color of this object. * * @param c - the color to set the background to. */ public void setBackground(Color c) { // Nothing to do here. } /** * Sets the bounds of this object in the form of a Rectangle object. * * @param r - the bounds to set the object o */ public void setBounds(Rectangle r) { // Nothing to do here. } /** * Sets the Cursor of this object. * * @param c - the new cursor */ public void setCursor(Cursor c) { cursor = c; } /** * Sets the enabled state of the object. * * @param b - boolean to enable or disable object */ public void setEnabled(boolean b) { // Nothing to do here. } /** * Sets the Font of this object. * * @param f - the new font. */ public void setFont(Font f) { // Nothing to do here. } /** * Sets the foreground color of this object. * * @param c - the new foreground color. */ public void setForeground(Color c) { // Nothing to do here. } /** * Sets the location of the object relative to the parent. * * @param p - the new location for the object. */ public void setLocation(Point p) { // Nothing to do here. } /** * Resizes this object so that it has width and height. * * @param d - the new size for the object. */ public void setSize(Dimension d) { // Nothing to do here. } /** * Sets the visible state of the object. * * @param b - sets the objects visibility. */ public void setVisible(boolean b) { // Nothing to do here. } } /** * Constructor */ public AccessibleJTree() { // Nothing to do here. } /** * Adds the specified selected item in the object to the object's selection. * * @param i - the row to add to the tree's selection */ public void addAccessibleSelection(int i) { addSelectionInterval(i, i); } /** * Clears the selection in the object, so that nothing in the object is selected. */ public void clearAccessibleSelection() { clearSelection(); } /** * Fire a visible data property change notification. */ public void fireVisibleDataPropertyChange() { treeDidChange(); } /** * Returns the Accessible child, if one exists, contained at the local * coordinate Point. * * @param p - the point of the accessible to get. * @return the accessible at point p. */ public Accessible getAccessibleAt(Point p) { TreePath tp = getClosestPathForLocation(p.x, p.y); if (tp != null) return new AccessibleJTreeNode(JTree.this, tp, null); return null; } /** * Return the nth Accessible child of the object. * * @param i - the accessible child to get * @return the i-th child */ public Accessible getAccessibleChild(int i) { return null; } /** * Returns the number of top-level children nodes of this JTree. * * @return the number of top-level children */ public int getAccessibleChildrenCount() { TreeModel model = getModel(); if (model != null) return model.getChildCount(model.getRoot()); return 0; } /** * Get the index of this object in its accessible parent. * * @return the index of this object. */ public int getAccessibleIndexInParent() { return 0; } /** * Get the role of this object. * * @return the role of this object */ public AccessibleRole getAccessibleRole() { return AccessibleRole.TREE; } /** * Get the AccessibleSelection associated with this object. * * @return the accessible selection of the tree */ public AccessibleSelection getAccessibleSelection() { TreeModel mod = getModel(); if (mod != null) return (new AccessibleJTreeNode(JTree.this, new TreePath(mod.getRoot()), null)).getAccessibleSelection(); return null; } /** * Returns an Accessible representing the specified selected item in the object. * * @return the i-th accessible in the selection */ public Accessible getAccessibleSelection(int i) { TreeModel mod = getModel(); if (mod != null) return (new AccessibleJTreeNode(JTree.this, new TreePath(mod.getRoot()), null)).getAccessibleSelection(i); return null; } /** * Returns the number of items currently selected. * * @return the number of selected accessibles. */ public int getAccessibleSelectionCount() { return getSelectionCount(); } /** * Returns true if the current child of this object is selected. * * @param i - the child of this object * @return true if the i-th child is selected. */ public boolean isAccessibleChildSelected(int i) { // Nothing to do here. return false; } /** * Removes the specified selected item in the object from the object's * selection. * * @param i - the i-th selected item to remove */ public void removeAccessibleSelection(int i) { removeSelectionInterval(i, i); } /** * Causes every selected item in the object to be selected if the object * supports multiple selections. */ public void selectAllAccessibleSelection() { if (getSelectionModel().getSelectionMode() != TreeSelectionModel.SINGLE_TREE_SELECTION) addSelectionInterval(0, getVisibleRowCount()); } /** * Tree Collapsed notification * * @param e - the event */ public void treeCollapsed(TreeExpansionEvent e) { fireTreeCollapsed(e.getPath()); } /** * Tree Model Expansion notification. * * @param e - the event */ public void treeExpanded(TreeExpansionEvent e) { fireTreeExpanded(e.getPath()); } /** * Tree Model Node change notification. * * @param e - the event */ public void treeNodesChanged(TreeModelEvent e) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -