?? accessiblehtml.java
字號:
getTextComponent().setCursor(cursor); } /** * Gets the Font of this object. * * @return the Font,if supported, for the object; otherwise, null * @see #setFont */ public Font getFont() { return getTextComponent().getFont(); } /** * Sets the Font of this object. * * @param f the new Font for the object * @see #getFont */ public void setFont(Font f) { getTextComponent().setFont(f); } /** * Gets the FontMetrics of this object. * * @param f the Font * @return the FontMetrics, if supported, the object; otherwise, null * @see #getFont */ public FontMetrics getFontMetrics(Font f) { return getTextComponent().getFontMetrics(f); } /** * Determines if the object is enabled. Objects that are enabled * will also have the AccessibleState.ENABLED state set in their * AccessibleStateSets. * * @return true if object is enabled; otherwise, false * @see #setEnabled * @see AccessibleContext#getAccessibleStateSet * @see AccessibleState#ENABLED * @see AccessibleStateSet */ public boolean isEnabled() { return getTextComponent().isEnabled(); } /** * Sets the enabled state of the object. * * @param b if true, enables this object; otherwise, disables it * @see #isEnabled */ public void setEnabled(boolean b) { getTextComponent().setEnabled(b); } /** * Determines if the object is visible. Note: this means that the * object intends to be visible; however, it may not be * showing on the screen because one of the objects that this object * is contained by is currently not visible. To determine if an object * is showing on the screen, use isShowing(). * <p>Objects that are visible will also have the * AccessibleState.VISIBLE state set in their AccessibleStateSets. * * @return true if object is visible; otherwise, false * @see #setVisible * @see AccessibleContext#getAccessibleStateSet * @see AccessibleState#VISIBLE * @see AccessibleStateSet */ public boolean isVisible() { return getTextComponent().isVisible(); } /** * Sets the visible state of the object. * * @param b if true, shows this object; otherwise, hides it * @see #isVisible */ public void setVisible(boolean b) { getTextComponent().setVisible(b); } /** * Determines if the object is showing. This is determined by checking * the visibility of the object and its ancestors. * Note: this * will return true even if the object is obscured by another (for * example, it is underneath a menu that was pulled down). * * @return true if object is showing; otherwise, false */ public boolean isShowing() { return getTextComponent().isShowing(); } /** * Checks whether the specified point is within this object's bounds, * where the point's x and y coordinates are defined to be relative * to the coordinate system of the object. * * @param p the Point relative to the coordinate system of the object * @return true if object contains Point; otherwise false * @see #getBounds */ public boolean contains(Point p) { Rectangle r = getBounds(); if (r != null) { return r.contains(p.x, p.y); } else { return false; } } /** * Returns the location of the object on the screen. * * @return the location of the object on screen; null if this object * is not on the screen * @see #getBounds * @see #getLocation */ public Point getLocationOnScreen() { Point editorLocation = getTextComponent().getLocationOnScreen(); Rectangle r = getBounds(); if (r != null) { return new Point(editorLocation.x + r.x, editorLocation.y + r.y); } else { return null; } } /** * 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 An instance of Point representing the top-left corner of the * object's bounds in the coordinate space of the screen; null if * this object or its parent are not on the screen * @see #getBounds * @see #getLocationOnScreen */ public Point getLocation() { Rectangle r = getBounds(); if (r != null) { return new Point(r.x, r.y); } else { return null; } } /** * Sets the location of the object relative to the parent. * @param p the new position for the top-left corner * @see #getLocation */ public void setLocation(Point p) { } /** * Gets the bounds of this object in the form of a Rectangle object. * The bounds specify this object's width, height, and location * relative to its parent. * * @return A rectangle indicating this component's bounds; null if * this object is not on the screen. * @see #contains */ public Rectangle getBounds() { return elementInfo.getBounds(); } /** * Sets the bounds of this object in the form of a Rectangle object. * The bounds specify this object's width, height, and location * relative to its parent. * * @param r rectangle indicating this component's bounds * @see #getBounds */ public void setBounds(Rectangle r) { } /** * Returns the size of this object in the form of a Dimension object. * The height field of the Dimension object contains this object's * height, and the width field of the Dimension object contains this * object's width. * * @return A Dimension object that indicates the size of this component; * null if this object is not on the screen * @see #setSize */ public Dimension getSize() { Rectangle r = getBounds(); if (r != null) { return new Dimension(r.width, r.height); } else { return null; } } /** * Resizes this object so that it has width and height. * * @param d The dimension specifying the new size of the object. * @see #getSize */ public void setSize(Dimension d) { Component comp = getTextComponent(); comp.setSize(d); } /** * Returns the Accessible child, if one exists, contained at the local * coordinate Point. * * @param p The point relative to the coordinate system of this object. * @return the Accessible, if it exists, at the specified location; * otherwise null */ public Accessible getAccessibleAt(Point p) { ElementInfo innerMostElement = getElementInfoAt(rootElementInfo, p); if (innerMostElement instanceof Accessible) { return (Accessible)innerMostElement; } else { return null; } } private ElementInfo getElementInfoAt(ElementInfo elementInfo, Point p) { if (elementInfo.getBounds() == null) { return null; } if (elementInfo.getChildCount() == 0 && elementInfo.getBounds().contains(p)) { return elementInfo; } else { if (elementInfo instanceof TableElementInfo) { // Handle table caption as a special case since it's the // only table child that is not a table row. ElementInfo captionInfo = ((TableElementInfo)elementInfo).getCaptionInfo(); if (captionInfo != null) { Rectangle bounds = captionInfo.getBounds(); if (bounds != null && bounds.contains(p)) { return captionInfo; } } } for (int i = 0; i < elementInfo.getChildCount(); i++){ ElementInfo childInfo = elementInfo.getChild(i); ElementInfo retValue = getElementInfoAt(childInfo, p); if (retValue != null) { return retValue; } } } return null; } /** * Returns whether this object can accept focus or not. Objects that * can accept focus will also have the AccessibleState.FOCUSABLE state * set in their AccessibleStateSets. * * @return true if object can accept focus; otherwise false * @see AccessibleContext#getAccessibleStateSet * @see AccessibleState#FOCUSABLE * @see AccessibleState#FOCUSED * @see AccessibleStateSet */ public boolean isFocusTraversable() { Component comp = getTextComponent(); if (comp instanceof JTextComponent) { if (((JTextComponent)comp).isEditable()) { return true; } } return false; } /** * Requests focus for this object. If this object cannot accept focus, * nothing will happen. Otherwise, the object will attempt to take * focus. * @see #isFocusTraversable */ public void requestFocus() { // TIGER - 4856191 if (! isFocusTraversable()) { return; } Component comp = getTextComponent(); if (comp instanceof JTextComponent) { comp.requestFocusInWindow(); try { if (elementInfo.validateIfNecessary()) { // set the caret position to the start of this component Element elem = elementInfo.getElement(); ((JTextComponent)comp).setCaretPosition(elem.getStartOffset()); // fire a AccessibleState.FOCUSED property change event AccessibleContext ac = editor.getAccessibleContext(); PropertyChangeEvent pce = new PropertyChangeEvent(this, AccessibleContext.ACCESSIBLE_STATE_PROPERTY, null, AccessibleState.FOCUSED); ac.firePropertyChange( AccessibleContext.ACCESSIBLE_STATE_PROPERTY, null, pce); } } catch (IllegalArgumentException e) { // don't fire property change event } } } /** * Adds the specified focus listener to receive focus events from this * component. * * @param l the focus listener * @see #removeFocusListener */ public void addFocusListener(FocusListener l) { getTextComponent().addFocusListener(l); } /** * Removes the specified focus listener so it no longer receives focus * events from this component. * * @param l the focus listener * @see #addFocusListener */ public void removeFocusListener(FocusListener l) { getTextComponent().removeFocusListener(l); } // ... end AccessibleComponent implementation } // ... end HTMLAccessibleContext /* * ElementInfo for text */ class TextElementInfo extends ElementInfo implements Accessible { TextElementInfo(Element element, ElementInfo parent) { super(element, parent); } // begin AccessibleText implementation ... private AccessibleContext accessibleContext; public AccessibleContext getAccessibleContext() { if (accessibleContext == null) { accessibleContext = new TextAccessibleContext(this); } return accessibleContext; } /* * AccessibleContext for text elements */ public class TextAccessibleContext extends HTMLAccessibleContext implements AccessibleText { public TextAccessibleContext(ElementInfo elementInfo) { super(elementInfo); } public AccessibleText getAccessibleText() { return this; } /** * Gets the accessibleName property of this object. The accessibleName * property of an object is a localized String that designates the purpose * of the object. For example, the accessibleName property of a label * or button might be the text of the label or button itself. In the * case of an object that doesn't display its name, the accessibleName * should still be set. For example, in the case of a text field used * to enter the name of a city, the accessibleName for the en_US locale * could be 'city.' * * @return the localized name of the object; null if this * object does not have a name * * @see #setAccessibleName */ public String getAccessibleName() { if (model != null) { return (String)model.getProperty(Document.TitleProperty); } else { return null; } } /** * Gets the accessibleDescription property of this object. If this * property isn't set, returns the content type of this * <code>JEditorPane</code> instead (e.g. "plain/text", "html/text"). * * @return the localized description of the object; <code>null</code> * if this object does not have a description * * @see #setAccessibleName */ public String getAccessibleDescription() { return editor.getContentType(); } /** * Gets the role of this object. The role of the object is the generic * purpose or use of the class of this object. For example, the role * of a push button is AccessibleRole.PUSH_BUTTON. The roles in * AccessibleRole are provided so component developers can pick from * a set of predefined roles. This enables assistive technologies to * provide a consistent interface to various tweaked subclasses of * components (e.g., use AccessibleRole.PUSH_BUTTON for all components * that act like a push button) as well as distinguish between sublasses * that behave differently (e.g., AccessibleRole.CHECK_BOX for check boxes * and AccessibleRole.RADIO_BUTTON for radio buttons). * <p>Note that the AccessibleRole class is also extensible, so * custom component developers can define their own AccessibleRole's * if the set of predefined roles is inadequate. * * @return an instance of AccessibleRole describing the role of the object * @see AccessibleRole */ public AccessibleRole getAccessibleRole() { return AccessibleRole.TEXT;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -