📄 menucomponent.java
字号:
*/ public FontMetrics getFontMetrics(Font font) { return MenuComponent.this.getToolkit().getFontMetrics(font); } /** * Returns the foreground color of the component, or null * if this property is unsupported. * <br /> * <br /> * This abstract class knows nothing about how the component * is drawn on screen, so this method simply returns the * default system text color used for rendering menus. * Concrete subclasses which handle the drawing of an onscreen * menu component should override this method and provide * the appropriate information. * * @return the default system text color for menus. * @see #setForeground(java.awt.Color) */ public Color getForeground() { return SystemColor.menuText; } /** * Returns the locale currently in use by this component. * <br /> * <br /> * This abstract class has no property relating to the * locale used by the component, so this method simply * returns the default locale for the current instance * of the Java Virtual Machine (JVM). Concrete subclasses * which maintain such a property should override this method * and provide the locale information more accurately. * * @return the default locale for this JVM instance. */ public Locale getLocale() { return Locale.getDefault(); } /** * Returns the location of the component, with co-ordinates * relative to the parent component and using the co-ordinate * space of the screen. Thus, the point (0,0) is the upper * left corner of the parent component. * <br /> * <br /> * Please note that this method depends on a correctly implemented * version of the <code>getBounds()</code> method. Subclasses * must provide the bounding rectangle via <code>getBounds()</code> * in order for this method to work. * * @return the location of the component, relative to its parent. * @see #setLocation(java.awt.Point) */ public Point getLocation() { /* Simply return the location of the bounding rectangle */ return getBounds().getLocation(); } /** * Returns the location of the component, with co-ordinates * relative to the screen. Thus, the point (0,0) is the upper * left corner of the screen. null is returned if the component * is either not on screen or if this property is unsupported. * <br /> * <br /> * This abstract class knows nothing about how the component * is drawn on screen, so this method simply returns null. * Concrete subclasses which handle the drawing of an onscreen * menu component should override this method and provide * the appropriate information. * * @return the location of the component, relative to the screen. */ public Point getLocationOnScreen() { return null; } /** * Returns the size of the component. * <br /> * <br /> * Please note that this method depends on a correctly implemented * version of the <code>getBounds()</code> method. Subclasses * must provide the bounding rectangle via <code>getBounds()</code> * in order for this method to work. * * @return the size of the component. * @see #setSize(java.awt.Dimension) */ public Dimension getSize() { /* Simply return the size of the bounding rectangle */ return getBounds().getSize(); } /** * Returns true if the accessible child specified by the supplied index * is currently selected. * <br /> * <br /> * As the existence of children can not be determined from * this abstract class, the implementation of this method * is left to subclasses. * * @param index the index of the accessible child to check for selection. * @return false. */ public boolean isAccessibleChildSelected(int index) { return false; } /** * Returns true if this component is currently enabled. * <br /> * <br /> * As this abstract component has no properties related to * its enabled or disabled state, the implementation of this * method is left to subclasses. * * @return false. * @see #setEnabled(boolean) */ public boolean isEnabled() { return false; } /** * Returns true if this component is included in the traversal * of the current focus from one component to the other. * <br /> * <br /> * As this abstract component has no properties related to * its ability to accept the focus, the implementation of this * method is left to subclasses. * * @return false. */ public boolean isFocusTraversable() { return false; } /** * Returns true if the component is being shown on screen. * A component is determined to be shown if it is visible, * and each parent component is also visible. Please note * that, even when a component is showing, it may still be * obscured by other components in front. This method only * determines if the component is being drawn on the screen. * <br /> * <br /> * As this abstract component and its parent have no properties * relating to visibility, the implementation of this method is * left to subclasses. * * @return false. * @see #isVisible() */ public boolean isShowing() { return false; } /** * Returns true if the component is visible. A component may * be visible but not drawn on the screen if one of its parent * components is not visible. To determine if the component is * actually drawn on screen, <code>isShowing()</code> should be * used. * <br /> * <br /> * As this abstract component has no properties relating to its * visibility, the implementation of this method is left to subclasses. * * @return false. * @see #isShowing() * @see #setVisible(boolean) */ public boolean isVisible() { return false; } /** * Removes the accessible child specified by the supplied index from * the list of currently selected children. If the child specified * is not selected, nothing happens. * <br /> * <br /> * As the existence of children can not be determined from * this abstract class, the implementation of this method * is left to subclasses. * * @param index the index of the <code>Accessible</code> child. */ public void removeAccessibleSelection(int index) { /* Subclasses with children should implement this */ } /** * Removes the specified focus listener from the list of registered * focus listeners for this component. * * @param listener the listener to remove. */ public void removeFocusListener(FocusListener listener) { /* Remove the focus listener from the chain */ focusListener = AWTEventMulticaster.remove(focusListener, listener); } /** * Requests that this component gains focus. This depends on the * component being focus traversable. * <br /> * <br /> * As this abstract component has no properties relating to its * focus traversability, or access to a peer with request focusing * abilities, the implementation of this method is left to subclasses. */ public void requestFocus() { /* Ignored */ } /** * Selects all <code>Accessible</code> children of this component which * it is possible to select. The component needs to support multiple * selections. * <br /> * <br /> * This abstract component provides a simplistic implementation of this * method, which ignores the ability of the component to support multiple * selections and simply uses <code>addAccessibleSelection</code> to * add each <code>Accessible</code> child to the selection. The last * <code>Accessible</code> component is thus selected for components * which don't support multiple selections. Concrete implementations should * override this with a more appopriate and efficient implementation, which * properly takes into account the ability of the component to support multiple * selections. */ public void selectAllAccessibleSelection() { /* Simply call addAccessibleSelection() on all accessible children */ for (int a = 0; a < getAccessibleChildrenCount(); ++a) { addAccessibleSelection(a); } } /** * Sets the background color of the component to that specified. * Unspecified behaviour occurs when null is given as the new * background color. * <br /> * <br /> * This abstract class knows nothing about how the component * is drawn on screen, so this method simply ignores the supplied * color and continues to use the default system color. * Concrete subclasses which handle the drawing of an onscreen * menu component should override this method and provide * the appropriate information. * * @param color the new color to use for the background. * @see #getBackground() */ public void setBackground(Color color) { /* Ignored */ } /** * Sets the height and width of the component, and its position * relative to this component's parent, to the values specified * by the supplied rectangle. Unspecified behaviour occurs when * null is given as the new bounds. * <br /> * <br /> * This abstract class knows nothing about how the component * is drawn on screen, so this method simply ignores the new * rectangle and continues to return null from <code>getBounds()</code>. * Concrete subclasses which handle the drawing of an onscreen * menu component should override this method and provide * the appropriate information. * * @param rectangle a rectangle which specifies the new bounds of * the component. * @see #getBounds() */ public void setBounds(Rectangle rectangle) { /* Ignored */ } /** * Sets the <code>Cursor</code> used when the pointer is positioned over the * component. Unspecified behaviour occurs when null is given as the new * cursor. * <br /> * <br /> * This abstract class knows nothing about how the component * is drawn on screen, so this method simply ignores the new cursor * and continues to return the default system cursor. Concrete * subclasses which handle the drawing of an onscreen menu component * may override this method and provide the appropriate information. * * @param cursor the new cursor to use. * @see #getCursor() */ public void setCursor(Cursor cursor) { /* Ignored */ } /** * Sets the enabled/disabled state of this component. * <br /> * <br /> * As this abstract component has no properties related to * its enabled or disabled state, the implementation of this * method is left to subclasses. * * @param enabled true if the component should be enabled, * false otherwise. * @see #isEnabled() */ public void setEnabled(boolean enabled) { /* Ignored */ } /** * Sets the <code>Font</code> used for text created by this component. * Unspecified behaviour occurs when null is given as the new * font. * * @param font the new font to use for text. * @see #getFont() */ public void setFont(Font font) { /* Call the method of the enclosing component */ MenuComponent.this.setFont(font); } /** * Sets the foreground color of the component to that specified. * Unspecified behaviour occurs when null is given as the new * background color. * <br /> * <br /> * This abstract class knows nothing about how the component * is drawn on screen, so this method simply ignores the supplied * color and continues to return the default system text color used * for rendering menus. * Concrete subclasses which handle the drawing of an onscreen * menu component should override this method and provide * the appropriate information. * * @param color the new foreground color. * @see #getForeground() */ public void setForeground(Color color) { /* Ignored */ } /** * Sets the location of the component, with co-ordinates * relative to the parent component and using the co-ordinate * space of the screen. Thus, the point (0,0) is the upper * left corner of the parent component. * <br /> * <br /> * Please note that this method depends on a correctly implemented * version of the <code>getBounds()</code> method. Subclasses * must provide the bounding rectangle via <code>getBounds()</code> * in order for this method to work. * * @param point the location of the component, relative to its parent. * @see #getLocation() */ public void setLocation(Point point) { getBounds().setLocation(point); } /** * Sets the size of the component. * <br /> * <br /> * Please note that this method depends on a correctly implemented * version of the <code>getBounds()</code> method. Subclasses * must provide the bounding rectangle via <code>getBounds()</code> * in order for this method to work. * * @param size the new size of the component. * @see #getSize() */ public void setSize(Dimension size) { getBounds().setSize(size); } /** * Sets the visibility state of the component. A component may * be visible but not drawn on the screen if one of its parent * components is not visible. To determine if the component is * actually drawn on screen, <code>isShowing()</code> should be * used. * <br /> * <br /> * As this abstract component has no properties relating to its * visibility, the implementation of this method is left to subclasses. * * @param visibility the new visibility of the component -- true if * the component is visible, false if not. * @see #isShowing() * @see #isVisible() */ public void setVisible(boolean visibility) { /* Ignored */ }} /* class AccessibleAWTMenuComponent */ } // class MenuComponent
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -