- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.AbstractButton
-
- All Implemented Interfaces:
-
ImageObserver,ItemSelectable,MenuContainer,Serializable,SwingConstants
- 已知直接子类:
-
JButton,JMenuItem,JToggleButton
@JavaBean(defaultProperty="UI") public abstract class AbstractButton extends JComponent implements ItemSelectable, SwingConstants
定义按钮和菜单项的常见行为。按钮可以配置,并在一定程度上控制,由
Actions。 使用带有按钮的Action除了直接配置按钮之外,还有很多好处。 有关更多详细信息,请参阅Swing Components SupportingAction,您可以在“Java教程”一节中的 How to Use Actions中找到更多信息。有关更多信息,请参阅“Java教程”中的“ How to Use Buttons, Check Boxes, and Radio Buttons ”一节。
警告:此类的序列化对象与将来的Swing版本不兼容。 当前的序列化支持适用于运行相同版本的Swing的应用程序之间的短期存储或RMI。 从1.4版本开始,所有JavaBeans的长期存储支持已被添加到
java.beans软件包中。 请参阅XMLEncoder。- 从以下版本开始:
- 1.2
- 另请参见:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class 描述 protected classAbstractButton.AccessibleAbstractButton该类实现AbstractButton类的可访问性支持。protected classAbstractButton.ButtonChangeListener扩展ChangeListener可串行化。-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
-
Field Summary
-
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
-
-
构造方法摘要
构造方法 Constructor 描述 AbstractButton()
-
方法摘要
所有方法 接口方法 具体的方法 弃用的方法 Modifier and Type 方法 描述 protected voidactionPropertyChanged(Action action, String propertyName)响应关联操作中的属性更改更新按钮的状态。voidaddActionListener(ActionListener l)添加一个ActionListener到按钮。voidaddChangeListener(ChangeListener l)在按钮中添加一个ChangeListener。protected voidaddImpl(Component comp, Object constraints, int index)在指定的索引处将指定的组件添加到此容器,有关此方法的完整说明,请参阅Container.addImpl(Component, Object, int)。voidaddItemListener(ItemListener l)添加ItemListener到checkbox。protected intcheckHorizontalKey(int key, String exception)验证key参数是否为horizontalAlignment和horizontalTextPosition属性的合法值。protected intcheckVerticalKey(int key, String exception)验证key参数是否为垂直属性的合法值。protected voidconfigurePropertiesFromAction(Action a)设置此按钮上的属性与指定的Action的属性相匹配。protected ActionListenercreateActionListener()返回ActionListener,它被添加到模型中。protected PropertyChangeListenercreateActionPropertyChangeListener(Action a)创建并返回一个PropertyChangeListener,负责监听指定的Action更改并更新相应的属性。protected ChangeListenercreateChangeListener()想要处理ChangeEvents子类可以覆盖这个,以返回另一个ChangeListener实现。protected ItemListenercreateItemListener()返回添加到模型的ItemListener。voiddoClick()以编程方式执行“点击”。voiddoClick(int pressTime)以编程方式执行“点击”。protected voidfireActionPerformed(ActionEvent event)通知所有在此事件类型上通知有兴趣的听众。protected voidfireItemStateChanged(ItemEvent event)通知所有在此事件类型上通知有兴趣的听众。protected voidfireStateChanged()通知所有在此事件类型上通知有兴趣的听众。ActiongetAction()返回当前设置Action这个ActionEvent源,或者null如果没有Action设置。StringgetActionCommand()返回此按钮的动作命令。ActionListener[]getActionListeners()返回一个使用addActionListener()添加到此AbstractButton的所有ActionListener的数组。ChangeListener[]getChangeListeners()返回使用addChangeListener()添加到此AbstractButton的所有ChangeListener的数组。IcongetDisabledIcon()返回按钮禁用时使用的图标。IcongetDisabledSelectedIcon()返回按钮在禁用和选择时使用的图标。intgetDisplayedMnemonicIndex()返回字符,作为索引,外观和感觉应提供装饰用于表示助记符。booleangetHideActionText()返回hideActionText属性的值,它决定按钮是否显示Action文本。intgetHorizontalAlignment()返回图标和文字的水平对齐方式。intgetHorizontalTextPosition()返回文本相对于图标的水平位置。IcongetIcon()返回默认图标。intgetIconTextGap()返回文本与此按钮中显示的图标之间的空格量。ItemListener[]getItemListeners()返回使用addItemListener()添加到此AbstractButton的所有ItemListener的数组。StringgetLabel()已过时。- 替换为getTextInsetsgetMargin()返回按钮边框和标签之间的边距。intgetMnemonic()从当前模型返回键盘助记符。ButtonModelgetModel()返回此按钮所代表的模型。longgetMultiClickThreshhold()获取鼠标按下事件之间所需的时间量(以毫秒为单位),用于生成相应的动作事件。IcongetPressedIcon()返回按钮的按下图标。IcongetRolloverIcon()返回按钮的翻转图标。IcongetRolloverSelectedIcon()返回按钮的翻转选择图标。IcongetSelectedIcon()返回按钮的选定图标。Object[]getSelectedObjects()如果没有选择该按钮,则返回一个包含标签的数组(长度为1)或null。StringgetText()返回按钮的文字。ButtonUIgetUI()返回渲染此组件的L&F对象。intgetVerticalAlignment()返回文本和图标的垂直对齐方式。intgetVerticalTextPosition()返回文本相对于图标的垂直位置。booleanimageUpdate(Image img, int infoflags, int x, int y, int w, int h)这被覆盖,以返回false,如果当前Icon的Image不等于在通过Imageimg。protected voidinit(String text, Icon icon)初始化AbstractButton。booleanisBorderPainted()获取borderPainted属性。booleanisContentAreaFilled()获取contentAreaFilled属性。booleanisFocusPainted()获取paintFocus属性。booleanisRolloverEnabled()获取rolloverEnabled属性。booleanisSelected()返回按钮的状态。protected voidpaintBorder(Graphics g)如果BorderPainted属性为true并且按钮具有边框,则BorderPainted按钮的边框。protected StringparamString()返回此AbstractButton的字符串表示AbstractButton。voidremoveActionListener(ActionListener l)从按钮中删除ActionListener。voidremoveChangeListener(ChangeListener l)从按钮中删除一个ChangeListener。voidremoveItemListener(ItemListener l)从按钮中删除ItemListener。voidremoveNotify()通知此组件它不再具有父组件。voidsetAction(Action a)设置Action。voidsetActionCommand(String actionCommand)设置此按钮的动作命令。voidsetBorderPainted(boolean b)设置borderPainted属性。voidsetContentAreaFilled(boolean b)设置contentAreaFilled属性。voidsetDisabledIcon(Icon disabledIcon)设置按钮的禁用图标。voidsetDisabledSelectedIcon(Icon disabledSelectedIcon)设置按钮的禁用选择图标。voidsetDisplayedMnemonicIndex(int index)提供关于文字中哪个字符应该被装饰以表示助记符的外观和感觉的提示。voidsetEnabled(boolean b)启用(或禁用)按钮。voidsetFocusPainted(boolean b)设置paintFocus属性,对于要绘制的焦点状态,属性必须为true。voidsetHideActionText(boolean hideActionText)设置hideActionText属性,它决定按钮是否显示Action文本。voidsetHorizontalAlignment(int alignment)设置图标和文字的水平对齐方式。voidsetHorizontalTextPosition(int textPosition)设置文本相对于图标的水平位置。voidsetIcon(Icon defaultIcon)设置按钮的默认图标。voidsetIconTextGap(int iconTextGap)如果设置了图标和文本属性,则此属性定义它们之间的空格。voidsetLabel(String label)已过时。- 替换为setText(text)voidsetLayout(LayoutManager mgr)设置此容器的布局管理器,有关此方法的完整说明,请参阅Container.setLayout(LayoutManager)。voidsetMargin(Insets m)在按钮的边框和标签之间设置边距空间。voidsetMnemonic(char mnemonic)这种方法现在已经过时了,请使用setMnemonic(int)设置一个按钮的助记符。voidsetMnemonic(int mnemonic)在当前型号上设置键盘助记符。voidsetModel(ButtonModel newModel)设置此按钮所代表的模型。voidsetMultiClickThreshhold(long threshhold)设置鼠标按下事件之间所需的时间量(以毫秒为单位),用于生成相应的动作事件。voidsetPressedIcon(Icon pressedIcon)设置按钮的按下图标。voidsetRolloverEnabled(boolean b)设置rolloverEnabled属性,必须是true才能发生翻转效果。voidsetRolloverIcon(Icon rolloverIcon)设置按钮的翻转图标。voidsetRolloverSelectedIcon(Icon rolloverSelectedIcon)设置按钮的滚动选择图标。voidsetSelected(boolean b)设置按钮的状态。voidsetSelectedIcon(Icon selectedIcon)设置按钮的选定图标。voidsetText(String text)设置按钮的文本。voidsetUI(ButtonUI ui)设置渲染此组件的L&F对象。voidsetVerticalAlignment(int alignment)设置图标和文本的垂直对齐方式。voidsetVerticalTextPosition(int textPosition)设置文本相对于图标的垂直位置。voidupdateUI()将UI属性重置为当前外观的值。-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
-
-
-
字段详细信息
-
MODEL_CHANGED_PROPERTY
public static final String MODEL_CHANGED_PROPERTY
标识按钮模型的变化。- 另请参见:
- Constant Field Values
-
TEXT_CHANGED_PROPERTY
public static final String TEXT_CHANGED_PROPERTY
标识按钮文本中的更改。- 另请参见:
- Constant Field Values
-
MNEMONIC_CHANGED_PROPERTY
public static final String MNEMONIC_CHANGED_PROPERTY
标识按钮的助记符的更改。- 另请参见:
- Constant Field Values
-
MARGIN_CHANGED_PROPERTY
public static final String MARGIN_CHANGED_PROPERTY
标识按钮边距的变化。- 另请参见:
- Constant Field Values
-
VERTICAL_ALIGNMENT_CHANGED_PROPERTY
public static final String VERTICAL_ALIGNMENT_CHANGED_PROPERTY
标识按钮垂直对齐方式的变化。- 另请参见:
- Constant Field Values
-
HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY
public static final String HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY
标识按钮的水平对齐方式的变化。- 另请参见:
- Constant Field Values
-
VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
public static final String VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
标识按钮垂直文本位置的变化。- 另请参见:
- Constant Field Values
-
HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY
public static final String HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY
标识按钮的水平文本位置的变化。- 另请参见:
- Constant Field Values
-
BORDER_PAINTED_CHANGED_PROPERTY
public static final String BORDER_PAINTED_CHANGED_PROPERTY
标识绘制边框或不绘制边框的更改。- 另请参见:
- Constant Field Values
-
FOCUS_PAINTED_CHANGED_PROPERTY
public static final String FOCUS_PAINTED_CHANGED_PROPERTY
标识在聚焦时突出显示边框的更改。- 另请参见:
- Constant Field Values
-
ROLLOVER_ENABLED_CHANGED_PROPERTY
public static final String ROLLOVER_ENABLED_CHANGED_PROPERTY
标识从翻转启用的禁用或恢复启用的更改。- 另请参见:
- Constant Field Values
-
CONTENT_AREA_FILLED_CHANGED_PROPERTY
public static final String CONTENT_AREA_FILLED_CHANGED_PROPERTY
标识使按钮绘制内容区域的更改。- 另请参见:
- Constant Field Values
-
ICON_CHANGED_PROPERTY
public static final String ICON_CHANGED_PROPERTY
标识代表该按钮的图标的更改。- 另请参见:
- Constant Field Values
-
PRESSED_ICON_CHANGED_PROPERTY
public static final String PRESSED_ICON_CHANGED_PROPERTY
标识按下按钮时使用的图标的更改。- 另请参见:
- Constant Field Values
-
SELECTED_ICON_CHANGED_PROPERTY
public static final String SELECTED_ICON_CHANGED_PROPERTY
标识在选择按钮时使用的图标的更改。- 另请参见:
- Constant Field Values
-
ROLLOVER_ICON_CHANGED_PROPERTY
public static final String ROLLOVER_ICON_CHANGED_PROPERTY
标识当光标在按钮上方使用的图标的更改。- 另请参见:
- Constant Field Values
-
ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY
public static final String ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY
标识当光标在按钮上方并且已被选择时使用的图标的更改。- 另请参见:
- Constant Field Values
-
DISABLED_ICON_CHANGED_PROPERTY
public static final String DISABLED_ICON_CHANGED_PROPERTY
标识当按钮被禁用时使用的图标的更改。- 另请参见:
- Constant Field Values
-
DISABLED_SELECTED_ICON_CHANGED_PROPERTY
public static final String DISABLED_SELECTED_ICON_CHANGED_PROPERTY
标识当按钮被禁用并选择时使用的图标的更改。- 另请参见:
- Constant Field Values
-
model
protected ButtonModel model
确定按钮状态的数据模型。
-
changeListener
protected ChangeListener changeListener
按钮型号changeListener。
-
actionListener
protected ActionListener actionListener
按钮型号ActionListener。
-
itemListener
protected ItemListener itemListener
按钮型号ItemListener。
-
changeEvent
protected transient ChangeEvent changeEvent
每个按钮实例只需要一个ChangeEvent因为事件的唯一状态是源属性。 生成的事件的来源总是“这”。
-
-
方法详细信息
-
setHideActionText
@BeanProperty(expert=true, description="Whether the text of the button should come from the <code>Action</code>.") public void setHideActionText(boolean hideActionText)
设置hideActionText属性,它决定按钮是否显示来自Action文本。 仅当按钮上安装了Action此功能才有用。- 参数
-
hideActionText-true如果按钮的text属性不应该反映Action; 默认为false - 从以下版本开始:
- 1.6
- 另请参见:
-
Swing Components Supporting
Action
-
getHideActionText
public boolean getHideActionText()
返回hideActionText属性的值,该属性确定按钮是否显示来自Action文本。 只有在按钮上安装了Action此功能才有用。- 结果
-
true如果按钮的text属性不应该反映Action; 默认值为false - 从以下版本开始:
- 1.6
-
getText
public String getText()
返回按钮的文字。- 结果
- 按钮文字
- 另请参见:
-
setText(java.lang.String)
-
setText
@BeanProperty(preferred=true, visualUpdate=true, description="The button\'s text.") public void setText(String text)
设置按钮的文本。- 参数
-
text- 用于设置文本的字符串 - 另请参见:
-
getText()
-
isSelected
public boolean isSelected()
返回按钮的状态。 如果选择了切换按钮,则为true,否则为false。- 结果
- 如果选择了切换按钮,则为true,否则为false
-
setSelected
public void setSelected(boolean b)
设置按钮的状态。 请注意,此方法不会触发actionEvent。 致电doClick以执行编程式操作更改。- 参数
-
b- 如果选择了按钮,则为true,否则为false
-
doClick
public void doClick()
以编程方式执行“点击”。 这样做与用户按下并释放按钮一样。
-
doClick
public void doClick(int pressTime)
以编程方式执行“点击”。 这样做与用户按下并释放按钮一样。 该按钮在视觉上“按下”pressTime毫秒。- 参数
-
pressTime- “按住”按钮的时间,以毫秒为单位
-
setMargin
@BeanProperty(visualUpdate=true, description="The space between the button\'s border and the label.") public void setMargin(Insets m)
在按钮的边框和标签之间设置边距空间。 设置为null将导致按钮使用默认边距。 按钮的默认Border对象将使用此值创建适当的边距。 但是,如果在按钮上设置了非默认边框,则Border对象有责任创建适当的边距空间(否则此属性将被有效地忽略)。- 参数
-
m- 边框和标签之间的空格
-
getMargin
public Insets getMargin()
返回按钮边框和标签之间的边距。- 结果
-
一个
Insets对象,指定了边框和标签之间的边距 - 另请参见:
-
setMargin(java.awt.Insets)
-
getIcon
public Icon getIcon()
返回默认图标。- 结果
-
默认为
Icon - 另请参见:
-
setIcon(javax.swing.Icon)
-
setIcon
@BeanProperty(visualUpdate=true, description="The button\'s default icon") public void setIcon(Icon defaultIcon)
设置按钮的默认图标。 如果没有明确设置的按下图标,该图标也被用作“按下”和“禁用”图标。- 参数
-
defaultIcon- 用作默认图像的图标 - 另请参见:
-
getIcon(),setPressedIcon(javax.swing.Icon)
-
getPressedIcon
public Icon getPressedIcon()
返回按钮的按下图标。- 结果
-
pressedIcon属性 - 另请参见:
-
setPressedIcon(javax.swing.Icon)
-
setPressedIcon
@BeanProperty(visualUpdate=true, description="The pressed icon for the button.") public void setPressedIcon(Icon pressedIcon)
设置按钮的按下图标。- 参数
-
pressedIcon- 用作“已按”图像的图标 - 另请参见:
-
getPressedIcon()
-
getSelectedIcon
public Icon getSelectedIcon()
返回按钮的选定图标。- 结果
-
selectedIcon属性 - 另请参见:
-
setSelectedIcon(javax.swing.Icon)
-
setSelectedIcon
@BeanProperty(visualUpdate=true, description="The selected icon for the button.") public void setSelectedIcon(Icon selectedIcon)
设置按钮的选定图标。- 参数
-
selectedIcon- 用作“选定”图像的图标 - 另请参见:
-
getSelectedIcon()
-
getRolloverIcon
public Icon getRolloverIcon()
返回按钮的翻转图标。- 结果
-
rolloverIcon属性 - 另请参见:
-
setRolloverIcon(javax.swing.Icon)
-
setRolloverIcon
@BeanProperty(visualUpdate=true, description="The rollover icon for the button.") public void setRolloverIcon(Icon rolloverIcon)
设置按钮的翻转图标。- 参数
-
rolloverIcon- 用作“翻转”图像的图标 - 另请参见:
-
getRolloverIcon()
-
getRolloverSelectedIcon
public Icon getRolloverSelectedIcon()
返回按钮的翻转选择图标。- 结果
-
rolloverSelectedIcon属性 - 另请参见:
-
setRolloverSelectedIcon(javax.swing.Icon)
-
setRolloverSelectedIcon
@BeanProperty(visualUpdate=true, description="The rollover selected icon for the button.") public void setRolloverSelectedIcon(Icon rolloverSelectedIcon)
设置按钮的滚动选择图标。- 参数
-
rolloverSelectedIcon- 用作“选择的翻转”图像的图标 - 另请参见:
-
getRolloverSelectedIcon()
-
getDisabledIcon
public Icon getDisabledIcon()
返回按钮禁用时使用的图标。 如果没有设置禁用的图标,则会将呼叫转移到外观和感觉上以构建适当的禁用图标。有些看起来和感觉可能不会渲染残疾人图标,在这种情况下,他们将忽略这一点。
- 结果
-
disabledIcon属性 - 另请参见:
-
getPressedIcon(),setDisabledIcon(javax.swing.Icon),LookAndFeel.getDisabledIcon(javax.swing.JComponent, javax.swing.Icon)
-
setDisabledIcon
@BeanProperty(visualUpdate=true, description="The disabled icon for the button.") public void setDisabledIcon(Icon disabledIcon)
设置按钮的禁用图标。- 参数
-
disabledIcon- 用作禁用图像的图标 - 另请参见:
-
getDisabledIcon()
-
getDisabledSelectedIcon
public Icon getDisabledSelectedIcon()
返回按钮在禁用和选择时使用的图标。 如果没有设置禁用的选择图标,则会将调用转发到LookAndFeel,以便从选择图标中设置适当的禁用图标,否则为getDisabledIcon()。一些看起来和感觉可能不会使残疾人选择的图标,在这种情况下,他们将忽略这一点。
- 结果
-
disabledSelectedIcon属性 - 另请参见:
-
getDisabledIcon(),setDisabledSelectedIcon(javax.swing.Icon),LookAndFeel.getDisabledSelectedIcon(javax.swing.JComponent, javax.swing.Icon)
-
setDisabledSelectedIcon
@BeanProperty(visualUpdate=true, description="The disabled selection icon for the button.") public void setDisabledSelectedIcon(Icon disabledSelectedIcon)
设置按钮的禁用选择图标。- 参数
-
disabledSelectedIcon- 用作禁用的选择图像的图标 - 另请参见:
-
getDisabledSelectedIcon()
-
getVerticalAlignment
public int getVerticalAlignment()
返回文本和图标的垂直对齐方式。- 结果
-
verticalAlignment属性,以下值之一:-
SwingConstants.CENTER(默认) -
SwingConstants.TOP -
SwingConstants.BOTTOM
-
-
setVerticalAlignment
@BeanProperty(visualUpdate=true, enumerationValues={"SwingConstants.TOP","SwingConstants.CENTER","SwingConstants.BOTTOM"}, description="The vertical alignment of the icon and text.") public void setVerticalAlignment(int alignment)
设置图标和文本的垂直对齐方式。- 参数
-
alignment- 以下值之一:-
SwingConstants.CENTER(默认) -
SwingConstants.TOP -
SwingConstants.BOTTOM
-
- 异常
-
IllegalArgumentException- 如果对齐方式不是上面列出的合法值之一
-
getHorizontalAlignment
public int getHorizontalAlignment()
返回图标和文字的水平对齐方式。AbstractButton的默认是SwingConstants.CENTER,但子类,如JCheckBox可以使用不同的默认值。- 结果
-
horizontalAlignment属性,以下值之一:-
SwingConstants.RIGHT -
SwingConstants.LEFT -
SwingConstants.CENTER -
SwingConstants.LEADING -
SwingConstants.TRAILING
-
-
setHorizontalAlignment
@BeanProperty(visualUpdate=true, enumerationValues={"SwingConstants.LEFT","SwingConstants.CENTER","SwingConstants.RIGHT","SwingConstants.LEADING","SwingConstants.TRAILING"}, description="The horizontal alignment of the icon and text.") public void setHorizontalAlignment(int alignment)
设置图标和文字的水平对齐方式。AbstractButton的默认是SwingConstants.CENTER,但子类,如JCheckBox可以使用不同的默认值。- 参数
-
alignment- 对齐值,以下值之一:-
SwingConstants.RIGHT -
SwingConstants.LEFT -
SwingConstants.CENTER -
SwingConstants.LEADING -
SwingConstants.TRAILING
-
- 异常
-
IllegalArgumentException- 如果对齐不是有效值之一
-
getVerticalTextPosition
public int getVerticalTextPosition()
返回文本相对于图标的垂直位置。- 结果
-
verticalTextPosition属性,以下值之一:-
SwingConstants.CENTER(默认) -
SwingConstants.TOP -
SwingConstants.BOTTOM
-
-
setVerticalTextPosition
@BeanProperty(visualUpdate=true, enumerationValues={"SwingConstants.TOP","SwingConstants.CENTER","SwingConstants.BOTTOM"}, description="The vertical position of the text relative to the icon.") public void setVerticalTextPosition(int textPosition)
设置文本相对于图标的垂直位置。- 参数
-
textPosition- 以下值之一:-
SwingConstants.CENTER(默认) -
SwingConstants.TOP -
SwingConstants.BOTTOM
-
-
getHorizontalTextPosition
public int getHorizontalTextPosition()
返回文本相对于图标的水平位置。- 结果
-
horizontalTextPosition属性,以下值之一:-
SwingConstants.RIGHT -
SwingConstants.LEFT -
SwingConstants.CENTER -
SwingConstants.LEADING -
SwingConstants.TRAILING(默认)
-
-
setHorizontalTextPosition
@BeanProperty(visualUpdate=true, enumerationValues={"SwingConstants.LEFT","SwingConstants.CENTER","SwingConstants.RIGHT","SwingConstants.LEADING","SwingConstants.TRAILING"}, description="The horizontal position of the text relative to the icon.") public void setHorizontalTextPosition(int textPosition)
设置文本相对于图标的水平位置。- 参数
-
textPosition- 以下值之一:-
SwingConstants.RIGHT -
SwingConstants.LEFT -
SwingConstants.CENTER -
SwingConstants.LEADING -
SwingConstants.TRAILING(默认)
-
- 异常
-
IllegalArgumentException- 如果textPosition不是上面列出的合法价值之一
-
getIconTextGap
public int getIconTextGap()
返回文本与此按钮中显示的图标之间的空格量。- 结果
- int等于文本和图标之间的像素数。
- 从以下版本开始:
- 1.4
- 另请参见:
-
setIconTextGap(int)
-
setIconTextGap
@BeanProperty(visualUpdate=true, description="If both the icon and text properties are set, this property defines the space between them.") public void setIconTextGap(int iconTextGap)
如果设置了图标和文本属性,则此属性定义它们之间的空格。此属性的默认值为4像素。
这是一个JavaBeans绑定属性。
- 参数
-
iconTextGap- 如果设置了这些属性,图标和文本之间的空格。 - 从以下版本开始:
- 1.4
- 另请参见:
-
getIconTextGap()
-
checkHorizontalKey
protected int checkHorizontalKey(int key, String exception)验证key的说法是对的合法值horizontalAlignment和horizontalTextPosition性能。 有效值为:-
SwingConstants.RIGHT -
SwingConstants.LEFT -
SwingConstants.CENTER -
SwingConstants.LEADING -
SwingConstants.TRAILING
- 参数
-
key- 要检查的属性值 -
exception- 要在无效值中抛出的IllegalArgumentException中使用的消息 - 结果
-
key论证 - 异常
-
IllegalArgumentException- 如果密钥不是上面列出的合法值之一 - 另请参见:
-
setHorizontalTextPosition(int),setHorizontalAlignment(int)
-
-
checkVerticalKey
protected int checkVerticalKey(int key, String exception)验证key参数是垂直属性的合法值。 有效值为:-
SwingConstants.CENTER -
SwingConstants.TOP -
SwingConstants.BOTTOM
- 参数
-
key- 要检查的属性值 -
exception- 要在无效值中抛出的IllegalArgumentException中要使用的消息 - 结果
-
key参数 - 异常
-
IllegalArgumentException- 如果密钥不是上面列出的合法值之一
-
-
removeNotify
public void removeNotify()
通知此组件它不再具有父组件。 调用此方法时,将删除在父组件链中设置的任何KeyboardAction。 该方法在内部被工具包调用,不应该被程序直接调用。
-
setActionCommand
public void setActionCommand(String actionCommand)
设置此按钮的动作命令。- 参数
-
actionCommand- 此按钮的动作命令
-
getActionCommand
public String getActionCommand()
返回此按钮的动作命令。- 结果
- 该按钮的动作命令
-
setAction
@BeanProperty(visualUpdate=true, description="the Action instance connected with this ActionEvent source") public void setAction(Action a)
设置Action。 新的Action替代以前设置的任何Action但不影响ActionListeners独立添加addActionListener。 如果Action已经是该注册表的ActionListener,则不会重新注册。设置
Action结果立即改变中描述的所有属性Swing Components SupportingAction。 随后,按钮的属性将自动更新为Action的属性更改。此方法使用三种其他方法来设置和帮助跟踪
Action的属性值。 它使用configurePropertiesFromAction方法立即更改按钮的属性。 要跟踪Action的属性值中的更改,此方法注册PropertyChangeListener返回的createActionPropertyChangeListener。 默认PropertyChangeListener调用actionPropertyChanged方法时的属性Action变化。- 参数
-
a-Action为AbstractButton,或null - 从以下版本开始:
- 1.3
- 另请参见:
-
Action,getAction(),configurePropertiesFromAction(javax.swing.Action),createActionPropertyChangeListener(javax.swing.Action),actionPropertyChanged(javax.swing.Action, java.lang.String)
-
getAction
public Action getAction()
返回当前设置Action这个ActionEvent源,或者null如果没有Action设置。- 结果
-
该
Action为ActionEvent源,或null - 从以下版本开始:
- 1.3
- 另请参见:
-
Action,setAction(javax.swing.Action)
-
configurePropertiesFromAction
protected void configurePropertiesFromAction(Action a)
设置此按钮上的属性与指定的Action的属性相匹配。 有关这个属性的详细信息,请参阅Swing Components SupportingAction。- 参数
-
a-Action获取属性的null,或null - 从以下版本开始:
- 1.3
- 另请参见:
-
Action,setAction(javax.swing.Action)
-
actionPropertyChanged
protected void actionPropertyChanged(Action action, String propertyName)
响应关联操作中的属性更改更新按钮的状态。 这种方法被调用从PropertyChangeListener从返回createActionPropertyChangeListener。 子类通常不需要调用它。 支持额外的Action属性的子类应该覆盖此和configurePropertiesFromAction。有关此方法设置的属性的列表,请参阅Swing Components Supporting
Action的表。- 参数
-
action- 与此按钮相关联的Action -
propertyName- 更改的属性的名称 - 从以下版本开始:
- 1.6
- 另请参见:
-
Action,configurePropertiesFromAction(javax.swing.Action)
-
createActionPropertyChangeListener
protected PropertyChangeListener createActionPropertyChangeListener(Action a)
创建并返回一个PropertyChangeListener,负责监听指定的Action更改并更新相应的属性。警告:如果你这个子类不创建一个匿名的内部类。 如果你一生的按钮将被绑定到
Action。- 参数
-
a- 按钮的动作 - 结果
-
PropertyChangeListener - 从以下版本开始:
- 1.3
- 另请参见:
-
Action,setAction(javax.swing.Action)
-
isBorderPainted
public boolean isBorderPainted()
获取borderPainted属性。- 结果
-
的价值
borderPainted属性 - 另请参见:
-
setBorderPainted(boolean)
-
setBorderPainted
@BeanProperty(visualUpdate=true, description="Whether the border should be painted.") public void setBorderPainted(boolean b)
设置borderPainted属性。 如果true和按钮有一个边框,边框被画。borderPainted属性的默认值为true。有些看起来和感觉可能不支持
borderPainted属性,在这种情况下,他们忽略这一点。- 参数
-
b- 如果true和border属性不是null,则绘制边框 - 另请参见:
-
isBorderPainted()
-
paintBorder
protected void paintBorder(Graphics g)
如果BorderPainted属性为true并且该按钮具有边框,则BorderPainted按钮的边框。- 重写:
-
paintBorder在JComponent - 参数
-
g- 要绘制的Graphics上下文 - 另请参见:
-
JComponent.paint(java.awt.Graphics),JComponent.setBorder(javax.swing.border.Border)
-
isFocusPainted
public boolean isFocusPainted()
获取paintFocus属性。- 结果
-
paintFocus属性 - 另请参见:
-
setFocusPainted(boolean)
-
setFocusPainted
@BeanProperty(visualUpdate=true, description="Whether focus should be painted") public void setFocusPainted(boolean b)
设置paintFocus属性,必须为true才能绘制对焦状态。paintFocus属性的默认值为true。 有些外观和感觉可能不会画出焦点状态; 他们将忽略此属性。- 参数
-
b- 如果是true,应该对焦状态 - 另请参见:
-
isFocusPainted()
-
isContentAreaFilled
public boolean isContentAreaFilled()
获取contentAreaFilled属性。- 结果
-
contentAreaFilled属性 - 另请参见:
-
setContentAreaFilled(boolean)
-
setContentAreaFilled
@BeanProperty(visualUpdate=true, description="Whether the button should paint the content area or leave it transparent.") public void setContentAreaFilled(boolean b)
设置contentAreaFilled属性。 如果true该按钮将绘制内容区域。 如果您希望有一个透明按钮,例如仅图标按钮,那么您应该将其设置为false。 不要拨打setOpaque(false)。contentAreaFilled属性的默认值为true。此功能可能会导致组件的不透明属性更改。
调用此功能的确切行为因分组和L&F-by-L&F而异。
- 参数
-
b- 如果为真,则填写内容; 如果虚拟内容区域未填写 - 另请参见:
-
isContentAreaFilled(),JComponent.setOpaque(boolean)
-
isRolloverEnabled
public boolean isRolloverEnabled()
获取rolloverEnabled属性。- 结果
-
该值为
rolloverEnabled属性 - 另请参见:
-
setRolloverEnabled(boolean)
-
setRolloverEnabled
@BeanProperty(visualUpdate=true, description="Whether rollover effects should be enabled.") public void setRolloverEnabled(boolean b)
设置rolloverEnabled属性,必须是true才能发生翻转效果。rolloverEnabled属性的默认值为false。 有些看起来和感觉可能不会实现翻滚效果; 他们将忽略此属性。- 参数
-
b- 如果是true,则应翻转翻转效果 - 另请参见:
-
isRolloverEnabled()
-
getMnemonic
public int getMnemonic()
从当前模型返回键盘助记符。- 结果
- 键盘助记符从模型
-
setMnemonic
@BeanProperty(visualUpdate=true, description="the keyboard character mnemonic") public void setMnemonic(int mnemonic)
在当前型号上设置键盘助记符。 助记符是关键,当与外观和感觉的无声修饰符(通常为Alt)组合时,如果焦点包含在此按钮的祖先窗口中的某处,激活该按钮。助记符必须对应于键盘上的单个键,并且应使用
VK_XXX定义的VK_XXX键码之一java.awt.event.KeyEvent。 这些代码和国际键盘的更广泛的代码可以通过java.awt.event.KeyEvent.getExtendedKeyCodeForChar获得。 助记符不区分大小写,因此具有相应键码的键事件将导致按钮被激活,无论Shift修改器是否被按下。如果在按钮的标签字符串中找到由助记符定义的字符,则它的第一次出现将被加下划线以向用户指示助记符。
- 参数
-
mnemonic- 表示助记符的关键代码 - 另请参见:
-
KeyEvent,setDisplayedMnemonicIndex(int)
-
setMnemonic
@BeanProperty(visualUpdate=true, description="the keyboard character mnemonic") public void setMnemonic(char mnemonic)
这种方法现在已经过时了,请使用setMnemonic(int)设置助记符按钮。 该方法仅用于处理“a”和“z”或“A”和“Z”之间的字符值。- 参数
-
mnemonic- 指定助记符值的char - 另请参见:
-
setMnemonic(int)
-
setDisplayedMnemonicIndex
@BeanProperty(visualUpdate=true, description="the index into the String to draw the keyboard character mnemonic at") public void setDisplayedMnemonicIndex(int index) throws IllegalArgumentException
提供关于文字中哪个字符应该被装饰以表示助记符的外观和感觉的提示。 不是所有的外观和感觉都可以支持这一点。 值-1表示没有助记符,助记符字符不包含在字符串中,或开发人员不希望显示助记符。这个值被更新为与助记符变化相关的属性(如助记符本身,文本...)。 如果您不希望默认字符被加下划线,您应该只需要调用它。 例如,如果文本为“另存为”,使用助记符为“a”,并且想要将“A”装饰为“保存A ”,则调用
setDisplayedMnemonicIndex(5)后,您必须调用setMnemonic(KeyEvent.VK_A)。- 参数
-
index- 索引到字符串下划线 - 异常
-
IllegalArgumentException- 如果index是> =文本的长度,或者<-1 - 从以下版本开始:
- 1.4
- 另请参见:
-
getDisplayedMnemonicIndex()
-
getDisplayedMnemonicIndex
public int getDisplayedMnemonicIndex()
返回字符,作为索引,外观和感觉应提供装饰用于表示助记符。- 结果
- 索引表示助记符号
- 从以下版本开始:
- 1.4
- 另请参见:
-
setDisplayedMnemonicIndex(int)
-
setMultiClickThreshhold
public void setMultiClickThreshhold(long threshhold)
设置鼠标按下事件之间所需的时间量(以毫秒为单位),用于生成相应的动作事件。 发生初始鼠标按钮(并且产生动作事件)后,任何后续的小鼠按压事件发生在小于阈值的间隔上将被忽略,并且不会产生相应的动作事件。 默认情况下,阈值为0,这意味着对于每个鼠标按下,将触发一个动作事件,无论鼠标点击发生的速度如何。 在不需要此行为的按钮中(例如,对话框中的“确定”按钮),该阈值应设置为适当的正值。- 参数
-
threshhold- 鼠标按压事件之间所需的时间量,以产生相应的动作事件 - 异常
-
IllegalArgumentException- 如果阈值<0 - 从以下版本开始:
- 1.4
- 另请参见:
-
getMultiClickThreshhold()
-
getMultiClickThreshhold
public long getMultiClickThreshhold()
获取鼠标按下事件之间所需的时间量(以毫秒为单位),用于生成相应的动作事件。- 结果
- 鼠标按压事件之间所需的时间量,以产生相应的动作事件
- 从以下版本开始:
- 1.4
- 另请参见:
-
setMultiClickThreshhold(long)
-
getModel
public ButtonModel getModel()
返回此按钮所代表的模型。- 结果
-
model属性 - 另请参见:
-
setModel(javax.swing.ButtonModel)
-
setModel
@BeanProperty(description="Model that the Button uses.") public void setModel(ButtonModel newModel)
设置此按钮所代表的模型。- 参数
-
newModel- 新的ButtonModel - 另请参见:
-
getModel()
-
getUI
public ButtonUI getUI()
返回渲染此组件的L&F对象。- 重写:
-
getUI在JComponent - 结果
- ButtonUI对象
- 另请参见:
-
setUI(javax.swing.plaf.ButtonUI)
-
setUI
@BeanProperty(hidden=true, visualUpdate=true, description="The UI object that implements the LookAndFeel.") public void setUI(ButtonUI ui)
设置渲染此组件的L&F对象。- 参数
-
ui-ButtonUIL&F对象 - 另请参见:
-
getUI()
-
updateUI
public void updateUI()
将UI属性重置为当前外观的值。AbstractButton子类型应该覆盖此更新UI。 例如,JButton可能会执行以下操作:setUI((ButtonUI)UIManager.getUI( "ButtonUI", "javax.swing.plaf.basic.BasicButtonUI", this));
-
addImpl
protected void addImpl(Component comp, Object constraints, int index)
将指定的组件添加到指定索引的此容器中,有关此方法的完整说明,请参见Container.addImpl(Component, Object, int)。- 重写:
-
addImpl在Container - 参数
-
comp- 要添加的组件 -
constraints- 表示此组件的布局约束的对象 -
index- 容器列表中插入组件的位置,其中-1表示附加到最后 - 异常
-
IllegalArgumentException- 如果index无效 -
IllegalArgumentException- 如果将容器的父项添加到自身 -
IllegalArgumentException- 如果向容器添加窗口 - 从以下版本开始:
- 1.5
- 另请参见:
-
Container.add(Component),Container.add(Component, int),Container.add(Component, java.lang.Object),Container.invalidate(),LayoutManager,LayoutManager2
-
setLayout
public void setLayout(LayoutManager mgr)
设置此容器的布局管理器,有关此方法的完整说明,请参阅Container.setLayout(LayoutManager)。- 重写:
-
setLayout在Container - 参数
-
mgr- 指定的布局管理器 - 从以下版本开始:
- 1.5
- 另请参见:
-
Container.doLayout(),Container.getLayout(),Container.invalidate()
-
addChangeListener
public void addChangeListener(ChangeListener l)
添加一个ChangeListener到按钮。- 参数
-
l- 要添加的侦听器
-
removeChangeListener
public void removeChangeListener(ChangeListener l)
从按钮中删除一个ChangeListener。- 参数
-
l- 要删除的侦听器
-
getChangeListeners
@BeanProperty(bound=false) public ChangeListener[] getChangeListeners()
返回使用addChangeListener()添加到此AbstractButton的所有ChangeListener的数组。- 结果
-
所有的
ChangeListener添加了,或者如果没有添加侦听器,则为空数组 - 从以下版本开始:
- 1.4
-
fireStateChanged
protected void fireStateChanged()
通知所有在此事件类型上通知有兴趣的听众。 事件实例被懒惰创建。- 另请参见:
-
EventListenerList
-
addActionListener
public void addActionListener(ActionListener l)
添加一个ActionListener按钮。- 参数
-
l- 要添加的ActionListener
-
removeActionListener
public void removeActionListener(ActionListener l)
从按钮中删除ActionListener。 如果听众是该按钮当前设置的Action,则Action设置为null。- 参数
-
l- 要删除的侦听器
-
getActionListeners
@BeanProperty(bound=false) public ActionListener[] getActionListeners()
返回使用addActionListener()添加到此AbstractButton的所有ActionListener的数组。- 结果
-
所有添加的
ActionListener或没有添加任何侦听器的空数组 - 从以下版本开始:
- 1.4
-
createChangeListener
protected ChangeListener createChangeListener()
想要处理ChangeEvents子类可以覆盖此值以返回另一个ChangeListener实现。- 结果
-
新的
ChangeListener
-
fireActionPerformed
protected void fireActionPerformed(ActionEvent event)
通知所有在此事件类型上通知有兴趣的听众。 事件实例使用event参数懒惰地创建。- 参数
-
event-ActionEvent对象 - 另请参见:
-
EventListenerList
-
fireItemStateChanged
protected void fireItemStateChanged(ItemEvent event)
通知所有在此事件类型上通知有兴趣的听众。 事件实例使用event参数懒惰创建。- 参数
-
event-ItemEvent对象 - 另请参见:
-
EventListenerList
-
createActionListener
protected ActionListener createActionListener()
返回添加到模型中的ActionListener。- 结果
-
ActionListener
-
createItemListener
protected ItemListener createItemListener()
返回添加到模型中的ItemListener。- 结果
-
ItemListener
-
setEnabled
public void setEnabled(boolean b)
启用(或禁用)按钮。- 重写:
-
setEnabled中的JComponent - 参数
-
b- true启用按钮,否则为false - 另请参见:
-
Component.isEnabled(),Component.isLightweight()
-
getLabel
@Deprecated public String getLabel()
已过时。 - 由getText返回标签文本。- 结果
-
一个
String包含标签
-
setLabel
@Deprecated @BeanProperty(description="Replace by setText(text)") public void setLabel(String label)
已过时。 - 由setText(text)设置标签文本。- 参数
-
label- 一个包含文本的String
-
addItemListener
public void addItemListener(ItemListener l)
添加ItemListener到checkbox。- Specified by:
-
addItemListener在接口ItemSelectable - 参数
-
l- 要添加的ItemListener - 另请参见:
-
ItemEvent
-
removeItemListener
public void removeItemListener(ItemListener l)
从按钮中删除ItemListener。- Specified by:
-
removeItemListener在接口ItemSelectable - 参数
-
l- 要删除的ItemListener - 另请参见:
-
ItemEvent
-
getItemListeners
@BeanProperty(bound=false) public ItemListener[] getItemListeners()
返回使用addItemListener()添加到此AbstractButton的所有ItemListener的数组。- 结果
-
所有添加的
ItemListener或一个空数组,如果没有添加侦听器 - 从以下版本开始:
- 1.4
-
getSelectedObjects
@BeanProperty(bound=false) public Object[] getSelectedObjects()
如果未选择按钮,则返回包含标签的数组(长度1)或null。- Specified by:
-
getSelectedObjects在接口ItemSelectable - 结果
-
一个包含1个对象的数组:按钮的文本,如果项目被选中;
否则
null
-
init
protected void init(String text, Icon icon)
初始化AbstractButton。- 参数
-
text- 按钮的文本 -
icon- 要在按钮上显示的图标图像
-
imageUpdate
public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h)
如果当前的Icon的Image不等于在Imageimg传递的值,则这被覆盖返回false。- Specified by:
-
imageUpdate在接口ImageObserver - 重写:
-
imageUpdateComponent - 参数
-
img- 要比较的Image -
infoflags- 用于在更新图像时重新绘制按钮的标志,并确定要绘制多少 -
x- x坐标 -
y- y坐标 -
w- 宽度 -
h- 高度 - 结果
-
false如果infoflags指示图像完全加载; 否则为true。 - 另请参见:
-
ImageObserver,Component.imageUpdate(java.awt.Image, int, int, int, int, int)
-
paramString
protected String paramString()
返回此AbstractButton的字符串表示AbstractButton。 该方法仅用于调试目的,并且返回的字符串的内容和格式可能因实现而异。 返回的字符串可能为空,但可能不是null。覆盖
paramString以提供有关JFC组件特定新方面的信息。- 重写:
-
paramString在JComponent - 结果
-
这个
AbstractButton的字符串表示AbstractButton
-
-