Module java.desktop

Class BasicArrowButton

所有已实现的接口:
ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible, SwingConstants
直接已知的子类:
MetalScrollButton

public class BasicArrowButton extends JButton implements SwingConstants
绘制一个缩放箭头的 JButton 对象,箭头指向基本方向之一。

警告: 该类的序列化对象将不兼容未来的 Swing 版本。当前的序列化支持适用于短期存储或在运行相同 Swing 版本的应用程序之间的 RMI。从 1.4 版本开始,已将所有 JavaBeans 的长期存储支持添加到 java.beans 包中。请参阅 XMLEncoder

  • Field Details

    • direction

      protected int direction
      箭头的方向。可以是 SwingConstants.NORTHSwingConstants.SOUTHSwingConstants.EASTSwingConstants.WEST 中的一个。
  • Constructor Details

    • BasicArrowButton

      public BasicArrowButton(int direction, Color background, Color shadow, Color darkShadow, Color highlight)
      创建一个绘制指定方向和指定颜色箭头的 BasicArrowButton
      参数:
      direction - 箭头的方向;可以是 SwingConstants.NORTHSwingConstants.SOUTHSwingConstants.EASTSwingConstants.WEST 中的一个
      background - 按钮的背景颜色
      shadow - 阴影颜色
      darkShadow - 深色阴影颜色
      highlight - 高亮颜色
      自版本:
      1.4
    • BasicArrowButton

      public BasicArrowButton(int direction)
      创建一个绘制指定方向箭头的 BasicArrowButton
      参数:
      direction - 箭头的方向;可以是 SwingConstants.NORTHSwingConstants.SOUTHSwingConstants.EASTSwingConstants.WEST 中的一个
  • Method Details

    • getDirection

      public int getDirection()
      返回箭头的方向。
      返回:
      箭头的方向
    • setDirection

      public void setDirection(int direction)
      设置箭头的方向。
      参数:
      direction - 箭头的方向;可以是 SwingConstants.NORTHSwingConstants.SOUTHSwingConstants.EASTSwingConstants.WEST 中的一个
    • getPreferredSize

      public Dimension getPreferredSize()
      返回 BasicArrowButton 的首选尺寸。
      覆盖:
      getPreferredSize 在类 JComponent
      返回:
      首选尺寸
      参见:
    • getMinimumSize

      public Dimension getMinimumSize()
      返回 BasicArrowButton 的最小尺寸。
      覆盖:
      getMinimumSize 在类 JComponent
      返回:
      最小尺寸
      参见:
    • getMaximumSize

      public Dimension getMaximumSize()
      返回 BasicArrowButton 的最大尺寸。
      覆盖:
      getMaximumSize 在类 JComponent
      返回:
      最大尺寸
      参见:
    • isFocusTraversable

      public boolean isFocusTraversable()
      返回箭头按钮是否应该获得焦点。 BasicArrowButton 通常用作复合组件(如 JScrollBarJComboBox)的子组件。由于复合组件通常会获得焦点,因此此方法被重写为返回 false
      覆盖:
      isFocusTraversable 在类 Component
      返回:
      false
      参见:
    • paintTriangle

      public void paintTriangle(Graphics g, int x, int y, int size, int direction, boolean isEnabled)
      绘制一个三角形。
      参数:
      g - 要绘制的 Graphics
      x - x 坐标
      y - y 坐标
      size - 要绘制的三角形大小
      direction - 绘制箭头的方向;可以是 SwingConstants.NORTHSwingConstants.SOUTHSwingConstants.EASTSwingConstants.WEST 中的一个
      isEnabled - 是否绘制启用的箭头