Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/accessibility/AccessibleComponent.java
38829 views
/*1* Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.accessibility;2627import java.awt.*;28import java.awt.event.*;2930/**31* The AccessibleComponent interface should be supported by any object32* that is rendered on the screen. This interface provides the standard33* mechanism for an assistive technology to determine and set the34* graphical representation of an object. Applications can determine35* if an object supports the AccessibleComponent interface by first36* obtaining its AccessibleContext37* and then calling the38* {@link AccessibleContext#getAccessibleComponent} method.39* If the return value is not null, the object supports this interface.40*41* @see Accessible42* @see Accessible#getAccessibleContext43* @see AccessibleContext44* @see AccessibleContext#getAccessibleComponent45*46* @author Peter Korn47* @author Hans Muller48* @author Willie Walker49*/50public interface AccessibleComponent {5152/**53* Gets the background color of this object.54*55* @return the background color, if supported, of the object;56* otherwise, null57* @see #setBackground58*/59public Color getBackground();6061/**62* Sets the background color of this object.63*64* @param c the new Color for the background65* @see #setBackground66*/67public void setBackground(Color c);6869/**70* Gets the foreground color of this object.71*72* @return the foreground color, if supported, of the object;73* otherwise, null74* @see #setForeground75*/76public Color getForeground();7778/**79* Sets the foreground color of this object.80*81* @param c the new Color for the foreground82* @see #getForeground83*/84public void setForeground(Color c);8586/**87* Gets the Cursor of this object.88*89* @return the Cursor, if supported, of the object; otherwise, null90* @see #setCursor91*/92public Cursor getCursor();9394/**95* Sets the Cursor of this object.96*97* @param cursor the new Cursor for the object98* @see #getCursor99*/100public void setCursor(Cursor cursor);101102/**103* Gets the Font of this object.104*105* @return the Font,if supported, for the object; otherwise, null106* @see #setFont107*/108public Font getFont();109110/**111* Sets the Font of this object.112*113* @param f the new Font for the object114* @see #getFont115*/116public void setFont(Font f);117118/**119* Gets the FontMetrics of this object.120*121* @param f the Font122* @return the FontMetrics, if supported, the object; otherwise, null123* @see #getFont124*/125public FontMetrics getFontMetrics(Font f);126127/**128* Determines if the object is enabled. Objects that are enabled129* will also have the AccessibleState.ENABLED state set in their130* AccessibleStateSets.131*132* @return true if object is enabled; otherwise, false133* @see #setEnabled134* @see AccessibleContext#getAccessibleStateSet135* @see AccessibleState#ENABLED136* @see AccessibleStateSet137*/138public boolean isEnabled();139140/**141* Sets the enabled state of the object.142*143* @param b if true, enables this object; otherwise, disables it144* @see #isEnabled145*/146public void setEnabled(boolean b);147148/**149* Determines if the object is visible. Note: this means that the150* object intends to be visible; however, it may not be151* showing on the screen because one of the objects that this object152* is contained by is currently not visible. To determine if an object is153* showing on the screen, use isShowing().154* <p>Objects that are visible will also have the155* AccessibleState.VISIBLE state set in their AccessibleStateSets.156*157* @return true if object is visible; otherwise, false158* @see #setVisible159* @see AccessibleContext#getAccessibleStateSet160* @see AccessibleState#VISIBLE161* @see AccessibleStateSet162*/163public boolean isVisible();164165/**166* Sets the visible state of the object.167*168* @param b if true, shows this object; otherwise, hides it169* @see #isVisible170*/171public void setVisible(boolean b);172173/**174* Determines if the object is showing. This is determined by checking175* the visibility of the object and its ancestors.176* Note: this177* will return true even if the object is obscured by another (for example,178* it is underneath a menu that was pulled down).179*180* @return true if object is showing; otherwise, false181*/182public boolean isShowing();183184/**185* Checks whether the specified point is within this object's bounds,186* where the point's x and y coordinates are defined to be relative to the187* coordinate system of the object.188*189* @param p the Point relative to the coordinate system of the object190* @return true if object contains Point; otherwise false191* @see #getBounds192*/193public boolean contains(Point p);194195/**196* Returns the location of the object on the screen.197*198* @return the location of the object on screen; null if this object199* is not on the screen200* @see #getBounds201* @see #getLocation202*/203public Point getLocationOnScreen();204205/**206* Gets the location of the object relative to the parent in the form207* of a point specifying the object's top-left corner in the screen's208* coordinate space.209*210* @return An instance of Point representing the top-left corner of the211* object's bounds in the coordinate space of the screen; null if212* this object or its parent are not on the screen213* @see #getBounds214* @see #getLocationOnScreen215*/216public Point getLocation();217218/**219* Sets the location of the object relative to the parent.220* @param p the new position for the top-left corner221* @see #getLocation222*/223public void setLocation(Point p);224225/**226* Gets the bounds of this object in the form of a Rectangle object.227* The bounds specify this object's width, height, and location228* relative to its parent.229*230* @return A rectangle indicating this component's bounds; null if231* this object is not on the screen.232* @see #contains233*/234public Rectangle getBounds();235236/**237* Sets the bounds of this object in the form of a Rectangle object.238* The bounds specify this object's width, height, and location239* relative to its parent.240*241* @param r rectangle indicating this component's bounds242* @see #getBounds243*/244public void setBounds(Rectangle r);245246/**247* Returns the size of this object in the form of a Dimension object.248* The height field of the Dimension object contains this object's249* height, and the width field of the Dimension object contains this250* object's width.251*252* @return A Dimension object that indicates the size of this component;253* null if this object is not on the screen254* @see #setSize255*/256public Dimension getSize();257258/**259* Resizes this object so that it has width and height.260*261* @param d The dimension specifying the new size of the object.262* @see #getSize263*/264public void setSize(Dimension d);265266/**267* Returns the Accessible child, if one exists, contained at the local268* coordinate Point.269*270* @param p The point relative to the coordinate system of this object.271* @return the Accessible, if it exists, at the specified location;272* otherwise null273*/274public Accessible getAccessibleAt(Point p);275276/**277* Returns whether this object can accept focus or not. Objects that278* can accept focus will also have the AccessibleState.FOCUSABLE state279* set in their AccessibleStateSets.280*281* @return true if object can accept focus; otherwise false282* @see AccessibleContext#getAccessibleStateSet283* @see AccessibleState#FOCUSABLE284* @see AccessibleState#FOCUSED285* @see AccessibleStateSet286*/287public boolean isFocusTraversable();288289/**290* Requests focus for this object. If this object cannot accept focus,291* nothing will happen. Otherwise, the object will attempt to take292* focus.293* @see #isFocusTraversable294*/295public void requestFocus();296297/**298* Adds the specified focus listener to receive focus events from this299* component.300*301* @param l the focus listener302* @see #removeFocusListener303*/304public void addFocusListener(FocusListener l);305306/**307* Removes the specified focus listener so it no longer receives focus308* events from this component.309*310* @param l the focus listener311* @see #addFocusListener312*/313public void removeFocusListener(FocusListener l);314}315316317