public abstract class AbstractButton extends JComponent implements ItemSelectable, SwingConstants
按钮可配置,并在一定程度上控制,通过Action
s。使用Action
用按钮直接配置按钮之外的许多好处。参考 Swing Components Supporting Action
更多细节,你可以在How to Use Actions找到更多信息,java教程中的一部分。
更多信息请参见How to Use Buttons, Check Boxes, and Radio Buttons,java教程中的一部分。
警告:序列化该类的对象与以后的Swing版本不兼容。当前的序列化支持适用于短期贮藏或RMI运行相同Swing版本的应用程序之间。为1.4,为所有JavaBeans™长期存储的支持已被添加到java.beans
包。请看XMLEncoder
。
Modifier and Type | Class and Description |
---|---|
protected class |
AbstractButton.AccessibleAbstractButton
这个类实现了对
AbstractButton 类可访问性支持。
|
protected class |
AbstractButton.ButtonChangeListener
延伸
ChangeListener 可序列化。
|
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
AbstractButton() |
Modifier and Type | Method and Description |
---|---|
protected void |
actionPropertyChanged(Action action, String propertyName)
更新按钮的状态以响应关联动作中的属性更改。
|
void |
addActionListener(ActionListener l)
增加了一个
ActionListener 的按钮。
|
void |
addChangeListener(ChangeListener l)
增加了一个
ChangeListener 的按钮。
|
protected void |
addImpl(Component comp, Object constraints, int index)
添加指定的组件容器指定索引处,指的是
Container.addImpl(Component, Object, int) 对本方法的完整描述。
|
void |
addItemListener(ItemListener l)
增加了一个
ItemListener 的
checkbox 。
|
protected int |
checkHorizontalKey(int key, String exception)
验证
key 论据是法律价值的
horizontalAlignment 和
horizontalTextPosition 性质。
|
protected int |
checkVerticalKey(int key, String exception)
验证
key 参数是垂直性质的法律价值。
|
protected void |
configurePropertiesFromAction(Action a)
设置这个按钮的属性与指定的
Action 。
|
protected ActionListener |
createActionListener() |
protected PropertyChangeListener |
createActionPropertyChangeListener(Action a)
创建并返回一个
PropertyChangeListener 负责侦听来自指定的
Action 变化和更新相应的属性。
|
protected ChangeListener |
createChangeListener()
子类,要处理不同的
ChangeEvents 可以重写此返回另一个
ChangeListener 实施。
|
protected ItemListener |
createItemListener() |
void |
doClick()
以编程方式执行“点击”。
|
void |
doClick(int pressTime)
以编程方式执行“点击”。
|
protected void |
fireActionPerformed(ActionEvent event)
通知所有的听众,关于这一事件的类型通知已注册的兴趣。
|
protected void |
fireItemStateChanged(ItemEvent event)
通知所有的听众,关于这一事件的类型通知已注册的兴趣。
|
protected void |
fireStateChanged()
通知所有的听众,关于这一事件的类型通知已注册的兴趣。
|
Action |
getAction()
返回当前设置为这个
ActionEvent 源
Action ,或
null 如果没有
Action 设置。
|
String |
getActionCommand()
返回此按钮的操作命令。
|
ActionListener[] |
getActionListeners()
返回所有的
ActionListener s数组添加到这个abstractbutton与addactionlistener()。
|
ChangeListener[] |
getChangeListeners()
返回所有的
ChangeListener s数组添加到这个abstractbutton与addchangelistener()。
|
Icon |
getDisabledIcon()
返回按钮时禁用按钮所使用的图标。
|
Icon |
getDisabledSelectedIcon()
返回按钮时,它的禁用和选定的图标。
|
int |
getDisplayedMnemonicIndex()
返回字符,作为指标,外观和感觉应该提供装饰为代表的助记符。
|
boolean |
getHideActionText()
返回的
hideActionText 属性的值,确定按钮是否显示文本从
Action 。
|
int |
getHorizontalAlignment()
返回图标和文本的水平对齐方式。
|
int |
getHorizontalTextPosition()
返回相对于图标的文本的水平位置。
|
Icon |
getIcon()
返回默认图标。
|
int |
getIconTextGap()
返回在该按钮上显示的文本和图标之间的空间量。
|
ItemListener[] |
getItemListeners()
返回所有的
ItemListener s数组添加到这个abstractbutton与additemlistener()。
|
String |
getLabel()
过时的。
-取代
getText
|
Insets |
getMargin()
返回按钮的边框和标签之间的边缘。
|
int |
getMnemonic()
返回键盘助记符从当前模型。
|
ButtonModel |
getModel()
返回此按钮表示的模型。
|
long |
getMultiClickThreshhold()
获取按钮的鼠标按下事件之间所需的时间(以毫秒为单位)以产生相应的动作事件。
|
Icon |
getPressedIcon()
返回按钮的按下图标。
|
Icon |
getRolloverIcon()
返回按钮的翻转图标。
|
Icon |
getRolloverSelectedIcon()
返回按钮的翻转选择图标。
|
Icon |
getSelectedIcon()
返回按钮的选定图标。
|
Object[] |
getSelectedObjects()
返回一个数组(长度1)包含标签或
null 如果按钮未被选中。
|
String |
getText()
返回按钮的文本。
|
ButtonUI |
getUI()
返回呈现此组件的L和F对象。
|
int |
getVerticalAlignment()
返回文本和图标的垂直对齐方式。
|
int |
getVerticalTextPosition()
返回相对于图标的文本的垂直位置。
|
boolean |
imageUpdate(Image img, int infoflags, int x, int y, int w, int h)
这是,如果当前
Icon 的
Image 不等于通过
Image
img 返回false。
|
protected void |
init(String text, Icon icon) |
boolean |
isBorderPainted()
得到
borderPainted 财产。
|
boolean |
isContentAreaFilled()
得到
contentAreaFilled 财产。
|
boolean |
isFocusPainted()
得到
paintFocus 财产。
|
boolean |
isRolloverEnabled()
得到
rolloverEnabled 财产。
|
boolean |
isSelected()
返回按钮的状态。
|
protected void |
paintBorder(Graphics g)
如果
BorderPainted 油漆按钮的边框属性为true,按钮有一个边界。
|
protected String |
paramString()
返回该
AbstractButton 字符串表示形式。
|
void |
removeActionListener(ActionListener l)
删除按钮
ActionListener 。
|
void |
removeChangeListener(ChangeListener l)
删除按钮changelistener。
|
void |
removeItemListener(ItemListener l)
删除按钮
ItemListener 。
|
void |
removeNotify()
通知这个组件,它不再有父组件。
|
void |
setAction(Action a)
集
Action 。
|
void |
setActionCommand(String actionCommand)
设置此按钮的操作命令。
|
void |
setBorderPainted(boolean b)
集
borderPainted 财产。
|
void |
setContentAreaFilled(boolean b)
集
contentAreaFilled 财产。
|
void |
setDisabledIcon(Icon disabledIcon)
设置按钮的禁用图标。
|
void |
setDisabledSelectedIcon(Icon disabledSelectedIcon)
设置按钮的禁用选择图标。
|
void |
setDisplayedMnemonicIndex(int index)
提供了一个暗示的外观和感觉对文本的字符应该装饰代表记忆。
|
void |
setEnabled(boolean b)
启用(或禁用)按钮。
|
void |
setFocusPainted(boolean b)
集
paintFocus 财产,必须要涂
true 焦点状态。
|
void |
setHideActionText(boolean hideActionText)
集
hideActionText 属性,决定从
Action 按钮显示的文本。
|
void |
setHorizontalAlignment(int alignment)
设置图标和文本的水平对齐方式。
|
void |
setHorizontalTextPosition(int textPosition)
设置文本的水平位置相对于图标。
|
void |
setIcon(Icon defaultIcon)
设置按钮的默认图标。
|
void |
setIconTextGap(int iconTextGap)
如果设置了图标和文本属性,则此属性定义了它们之间的空间。
|
void |
setLabel(String label)
过时的。
-取代
setText(text)
|
void |
setLayout(LayoutManager mgr)
设置此容器的布局管理器,是指
Container.setLayout(LayoutManager) 对本方法的完整描述。
|
void |
setMargin(Insets m)
设置按钮的边框和标签之间的间隔空间。
|
void |
setMnemonic(char mnemonic)
这种方法已经过时了,请用
setMnemonic(int) 为按钮设置的记忆。
|
void |
setMnemonic(int mnemonic)
集记忆模式对当前的键盘。
|
void |
setModel(ButtonModel newModel)
设置此按钮表示的模型。
|
void |
setMultiClickThreshhold(long threshhold)
设置按钮的鼠标按下事件之间所需的时间(以毫秒为单位),以产生相应的动作事件。
|
void |
setPressedIcon(Icon pressedIcon)
设置按钮的按下图标。
|
void |
setRolloverEnabled(boolean b)
集
rolloverEnabled 财产,必须发生
true 翻转效果。
|
void |
setRolloverIcon(Icon rolloverIcon)
设置按钮的翻转图标。
|
void |
setRolloverSelectedIcon(Icon rolloverSelectedIcon)
设置按钮的翻转选择图标。
|
void |
setSelected(boolean b)
设置按钮的状态。
|
void |
setSelectedIcon(Icon selectedIcon)
设置按钮的选定图标。
|
void |
setText(String text)
设置按钮的文本。
|
void |
setUI(ButtonUI ui)
设置呈现此组件的“L”和F对象。
|
void |
setVerticalAlignment(int alignment)
设置图标和文本的垂直对齐方式。
|
void |
setVerticalTextPosition(int textPosition)
设置文本的垂直位置相对于图标。
|
void |
updateUI()
重置UI属性从目前看价值和感觉。
|
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
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
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, getPeer, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final String MODEL_CHANGED_PROPERTY
public static final String TEXT_CHANGED_PROPERTY
public static final String MNEMONIC_CHANGED_PROPERTY
public static final String MARGIN_CHANGED_PROPERTY
public static final String VERTICAL_ALIGNMENT_CHANGED_PROPERTY
public static final String HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY
public static final String VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
public static final String HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY
public static final String BORDER_PAINTED_CHANGED_PROPERTY
public static final String FOCUS_PAINTED_CHANGED_PROPERTY
public static final String ROLLOVER_ENABLED_CHANGED_PROPERTY
public static final String CONTENT_AREA_FILLED_CHANGED_PROPERTY
public static final String ICON_CHANGED_PROPERTY
public static final String PRESSED_ICON_CHANGED_PROPERTY
public static final String SELECTED_ICON_CHANGED_PROPERTY
public static final String ROLLOVER_ICON_CHANGED_PROPERTY
public static final String ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY
public static final String DISABLED_ICON_CHANGED_PROPERTY
public static final String DISABLED_SELECTED_ICON_CHANGED_PROPERTY
protected ButtonModel model
protected ChangeListener changeListener
changeListener
模型。
protected ActionListener actionListener
ActionListener
模型。
protected ItemListener itemListener
ItemListener
模型。
protected transient ChangeEvent changeEvent
ChangeEvent
是需要每个按钮实例事件以来唯一的国家财产的来源。事件产生的源永远是“这”。
public void setHideActionText(boolean hideActionText)
hideActionText
属性,决定按钮显示的文字从
Action
。这是有用的只有一个
Action
已安装按钮。
hideActionText
-
true
如果按钮的
text
财产不应反映的
Action
;默认是
false
Action
public boolean getHideActionText()
hideActionText
属性的值,确定按钮是否显示文本从
Action
。这是有用的只有一个
Action
已安装按钮。
true
如果按钮的
text
财产不应反映的
Action
;默认是
false
public String getText()
setText(java.lang.String)
public boolean isSelected()
public void setSelected(boolean b)
actionEvent
。电话
doClick
执行计划的动作变化。
b
-如果按钮被选中,否则为false
public void doClick()
public void doClick(int pressTime)
pressTime
毫秒。
pressTime
-时间“按住”按钮,以毫秒为单位
public void setMargin(Insets m)
null
将会使按钮使用默认的边缘。按钮的默认
Border
对象将使用此值来适当的利润创造。然而,如果一个非默认的边界上设置的按钮,这是
Border
对象的责任创造适当的利润空间(其他属性可以有效地被忽略)。
m
-边框和标签之间的空间
public Insets getMargin()
Insets
对象指定按钮的边框和标签之间的差距
setMargin(java.awt.Insets)
public Icon getIcon()
Icon
setIcon(javax.swing.Icon)
public void setIcon(Icon defaultIcon)
defaultIcon
-作为默认图像的图标
getIcon()
,
setPressedIcon(javax.swing.Icon)
public Icon getPressedIcon()
pressedIcon
财产
setPressedIcon(javax.swing.Icon)
public void setPressedIcon(Icon pressedIcon)
pressedIcon
的图标作为“压”形象
getPressedIcon()
public Icon getSelectedIcon()
selectedIcon
财产
setSelectedIcon(javax.swing.Icon)
public void setSelectedIcon(Icon selectedIcon)
selectedIcon
的图标作为“选择”的形象
getSelectedIcon()
public Icon getRolloverIcon()
rolloverIcon
财产
setRolloverIcon(javax.swing.Icon)
public void setRolloverIcon(Icon rolloverIcon)
rolloverIcon
的图标作为“翻转”形象
getRolloverIcon()
public Icon getRolloverSelectedIcon()
rolloverSelectedIcon
财产
setRolloverSelectedIcon(javax.swing.Icon)
public void setRolloverSelectedIcon(Icon rolloverSelectedIcon)
rolloverSelectedIcon
的图标作为所“翻转”形象
getRolloverSelectedIcon()
public Icon getDisabledIcon()
一些外观和感觉可能不会渲染禁用图标,在这种情况下,他们会忽略这个。
disabledIcon
财产
getPressedIcon()
,
setDisabledIcon(javax.swing.Icon)
,
LookAndFeel.getDisabledIcon(javax.swing.JComponent, javax.swing.Icon)
public void setDisabledIcon(Icon disabledIcon)
disabledIcon
作为残疾人形象的图标
getDisabledIcon()
public Icon getDisabledSelectedIcon()
getDisabledIcon()
否则。
一些外观和感觉可能不会渲染禁用选定的图标,在这种情况下,他们会忽略这个。
disabledSelectedIcon
财产
getDisabledIcon()
,
setDisabledSelectedIcon(javax.swing.Icon)
,
LookAndFeel.getDisabledSelectedIcon(javax.swing.JComponent, javax.swing.Icon)
public void setDisabledSelectedIcon(Icon disabledSelectedIcon)
disabledSelectedIcon
作为残疾人选择图像的图标
getDisabledSelectedIcon()
public int getVerticalAlignment()
verticalAlignment
财产,下列值之一:
SwingConstants.CENTER
(默认)SwingConstants.TOP
SwingConstants.BOTTOM
public void setVerticalAlignment(int alignment)
alignment
-以下值之一:
SwingConstants.CENTER
(默认)SwingConstants.TOP
SwingConstants.BOTTOM
IllegalArgumentException
如果对准不是上面列出的法律价值
public int getHorizontalAlignment()
AbstractButton
违约
SwingConstants.CENTER
,但是子类
JCheckBox
可能使用不同的默认。
horizontalAlignment
财产,下列值之一:
SwingConstants.RIGHT
SwingConstants.LEFT
SwingConstants.CENTER
SwingConstants.LEADING
SwingConstants.TRAILING
public void setHorizontalAlignment(int alignment)
AbstractButton
违约
SwingConstants.CENTER
,但是子类
JCheckBox
可能使用不同的默认。
alignment
的对齐值,下列值之一:
SwingConstants.RIGHT
SwingConstants.LEFT
SwingConstants.CENTER
SwingConstants.LEADING
SwingConstants.TRAILING
IllegalArgumentException
如果对准的是没有一个有效值
public int getVerticalTextPosition()
verticalTextPosition
财产,下列值之一:
SwingConstants.CENTER
(默认)SwingConstants.TOP
SwingConstants.BOTTOM
public void setVerticalTextPosition(int textPosition)
textPosition
-以下值之一:
SwingConstants.CENTER
(默认)SwingConstants.TOP
SwingConstants.BOTTOM
public int getHorizontalTextPosition()
horizontalTextPosition
财产,下列值之一:
SwingConstants.RIGHT
SwingConstants.LEFT
SwingConstants.CENTER
SwingConstants.LEADING
SwingConstants.TRAILING
(默认)public void setHorizontalTextPosition(int textPosition)
textPosition
-以下值之一:
SwingConstants.RIGHT
SwingConstants.LEFT
SwingConstants.CENTER
SwingConstants.LEADING
SwingConstants.TRAILING
(默认)IllegalArgumentException
-如果
textPosition
不是上面列出的法律价值
public int getIconTextGap()
setIconTextGap(int)
public void setIconTextGap(int iconTextGap)
此属性的默认值为4像素。
这是一个JavaBeans属性绑定。
getIconTextGap()
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)
protected int checkVerticalKey(int key, String exception)
key
参数是垂直性质的法律价值。有效值为:
SwingConstants.CENTER
SwingConstants.TOP
SwingConstants.BOTTOM
key
-属性值检查
exception
-消息中使用的
IllegalArgumentException
,抛出一个无效的值
key
IllegalArgumentException
如果关键不是上面列出的法律价值
public void removeNotify()
KeyboardAction
s设置在链父组件被移除。这种方法被内部调用的工具包,不应该直接调用程序。
removeNotify
方法重写,继承类
JComponent
JComponent.registerKeyboardAction(java.awt.event.ActionListener, java.lang.String, javax.swing.KeyStroke, int)
public void setActionCommand(String actionCommand)
actionCommand
-这个按钮的动作命令
public String getActionCommand()
public void setAction(Action a)
Action
。新
Action
取代任何先前设定的
Action
但不影响
ActionListeners
独立加
addActionListener
。如果
Action
已经注册
ActionListener
的按钮,它不是重新注册。
立即改变所有的属性描述 Swing Components Supporting Action
设置Action
结果。随后,该按钮的属性为Action
特性改变的自动更新。
该方法采用其他三种方法来设置和帮助跟踪Action
的属性值。它使用configurePropertiesFromAction
方法立即改变按钮的属性。跟踪在Action
的属性值的变化,该方法返回的PropertyChangeListener
createActionPropertyChangeListener
寄存器。默认PropertyChangeListener
调用actionPropertyChanged
方法在Action
变化特性。
a
为
AbstractButton
的
Action
,或
null
Action
,
getAction()
,
configurePropertiesFromAction(javax.swing.Action)
,
createActionPropertyChangeListener(javax.swing.Action)
,
actionPropertyChanged(javax.swing.Action, java.lang.String)
public Action getAction()
ActionEvent
源
Action
,或
null
如果没有
Action
设置。
ActionEvent
源
Action
,或
null
Action
,
setAction(javax.swing.Action)
protected void configurePropertiesFromAction(Action a)
Action
。参考
Swing Components Supporting Action
为更多的细节,这一集的性质。
a
-从中得到性能的
Action
,或
null
Action
,
setAction(javax.swing.Action)
protected void actionPropertyChanged(Action action, String propertyName)
PropertyChangeListener
调用返回
createActionPropertyChangeListener
。子类通常不需要调用这个。子类,支持额外的
Action
性能应重写此和
configurePropertiesFromAction
。
引用该表在属性的列表方法 Swing Components Supporting Action
集。
action
-这个按钮相关的
Action
propertyName
-改变属性的名称
Action
,
configurePropertiesFromAction(javax.swing.Action)
protected PropertyChangeListener createActionPropertyChangeListener(Action a)
PropertyChangeListener
负责侦听来自指定的
Action
变化和更新相应的属性。
警告:如果子类不创建一个匿名内部类。如果你的按钮的寿命将绑定到的Action
。
a
-按钮的动作
Action
,
setAction(javax.swing.Action)
public boolean isBorderPainted()
borderPainted
财产。
borderPainted
属性的值
setBorderPainted(boolean)
public void setBorderPainted(boolean b)
borderPainted
财产。如果
true
和按钮有一个边界,边界是画。为
borderPainted
属性的默认值是
true
。
一些看起来和感觉可能不支持borderPainted
属性,在这种情况下,他们忽略了这。
b
和边界属性不
null
,边境上
isBorderPainted()
protected void paintBorder(Graphics g)
BorderPainted
油漆按钮的边框属性为true,按钮有一个边界。
paintBorder
方法重写,继承类
JComponent
g
-
Graphics
背景的画
JComponent.paint(java.awt.Graphics)
,
JComponent.setBorder(javax.swing.border.Border)
public boolean isFocusPainted()
paintFocus
财产。
paintFocus
财产
setFocusPainted(boolean)
public void setFocusPainted(boolean b)
paintFocus
财产,必须要涂
true
焦点状态。为
paintFocus
属性的默认值是
true
。一些看起来和感觉不可能画的重点国家;他们会忽略该属性。
b
-如果
true
,焦点状态应涂
isFocusPainted()
public boolean isContentAreaFilled()
contentAreaFilled
财产。
contentAreaFilled
财产
setContentAreaFilled(boolean)
public void setContentAreaFilled(boolean b)
contentAreaFilled
财产。如果
true
按钮将油漆区的内容。如果你希望有一个透明的按钮,如图标的按钮,例如,那么你应该把这
false
。不要叫
setOpaque(false)
。在
contentAreaFilled
属性
true
默认值。
此功能可能会导致组件的不透明属性更改。
的调用这个函数的确切行为变化的成分和L和f-by-l & F基础组件。
b
-如果属实,内容应填写;如果虚假内容区域不填充
isContentAreaFilled()
,
JComponent.setOpaque(boolean)
public boolean isRolloverEnabled()
rolloverEnabled
财产。
rolloverEnabled
属性的值
setRolloverEnabled(boolean)
public void setRolloverEnabled(boolean b)
rolloverEnabled
财产,必须
true
影响发生侧翻。为
rolloverEnabled
属性的默认值是
false
。一些外观和感觉可能不会实现翻转效果,他们将忽略此属性。
b
-如果
true
,翻转效果应涂
isRolloverEnabled()
public int getMnemonic()
public void setMnemonic(int mnemonic)
一种记忆必须对应键盘上的一个关键,应该使用一个指定的键码定义在java.awt.event.KeyEvent
VK_XXX
。这些代码与广泛的代码可以通过java.awt.event.KeyEvent.getExtendedKeyCodeForChar
国际键盘。记忆是不区分大小写,因此,与相应的键码关键事件会导致按钮被激活是否按下了shift。
如果记忆定义的字符是按钮的标签字符串中第一次出现,它将下划线指示用户记忆。
mnemonic
-代表了记忆的关键代码
KeyEvent
,
setDisplayedMnemonicIndex(int)
public void setMnemonic(char mnemonic)
setMnemonic(int)
为按钮设置的记忆。此方法只设计用来处理“A”和“Z”或“A”和“Z”之间的字符值。
mnemonic
-一个字符指定记忆价值
setMnemonic(int)
public void setDisplayedMnemonicIndex(int index) throws IllegalArgumentException
这个值是有关记忆的性能变化,更新(如记忆本身,文字…)。如果你不希望默认字符被下划线,你应该只需要调用这个。例如,如果文本是“另存为”,在“A”的记忆,和你想要的'加以装饰,为节省一s ',你必须调用后调用setMnemonic(KeyEvent.VK_A)
setDisplayedMnemonicIndex(5)
。
index
指数为字符串下划线
IllegalArgumentException
将抛出如果
index
> =长度的文本,或<1
getDisplayedMnemonicIndex()
public int getDisplayedMnemonicIndex()
setDisplayedMnemonicIndex(int)
public void setMultiClickThreshhold(long threshhold)
threshhold
-所需的鼠标按下事件之间产生相应的动作事件的时间
IllegalArgumentException
如果阈值小于0
getMultiClickThreshhold()
public long getMultiClickThreshhold()
setMultiClickThreshhold(long)
public ButtonModel getModel()
model
财产
setModel(javax.swing.ButtonModel)
public void setModel(ButtonModel newModel)
newModel
-新的
ButtonModel
getModel()
public ButtonUI getUI()
setUI(javax.swing.plaf.ButtonUI)
public void updateUI()
AbstractButton
应重写此更新的用户界面。例如,
JButton
可能做到以下几点:
setui((ButtonUI)”。getui(“ButtonUI”、“javax.摆动。PLAF。基本。basicbuttonui”,这));
protected void addImpl(Component comp, Object constraints, int index)
Container.addImpl(Component, Object, int)
对本方法的完整描述。
addImpl
方法重写,继承类
Container
comp
-要添加的组件
constraints
物体表达这个组件的布局约束
index
-在列表容器的位置插入成分,其中
-1
意味着追加到最后
IllegalArgumentException
-如果
index
无效
IllegalArgumentException
如果添加容器的家长本身
IllegalArgumentException
如果增加一个窗口一个容器
Container.add(Component)
,
Container.add(Component, int)
,
Container.add(Component, java.lang.Object)
,
Container.invalidate()
,
LayoutManager
,
LayoutManager2
public void setLayout(LayoutManager mgr)
Container.setLayout(LayoutManager)
对本方法的完整描述。
setLayout
方法重写,继承类
Container
mgr
-指定的布局管理器
Container.doLayout()
,
Container.getLayout()
,
Container.invalidate()
public void addChangeListener(ChangeListener l)
ChangeListener
的按钮。
l
-监听器被添加
public void removeChangeListener(ChangeListener l)
l
-听者被删除
public ChangeListener[] getChangeListeners()
ChangeListener
s数组添加到这个abstractbutton与addchangelistener()。
ChangeListener
s说如果没有听众已添加一个空数组
protected void fireStateChanged()
EventListenerList
public void addActionListener(ActionListener l)
ActionListener
的按钮。
l
-
ActionListener
加以补充
public void removeActionListener(ActionListener l)
ActionListener
。如果听众是目前为按钮设置
Action
,然后
Action
设置
null
。
l
-听者被删除
public ActionListener[] getActionListeners()
ActionListener
s数组添加到这个abstractbutton与addactionlistener()。
ActionListener
s说如果没有听众已添加一个空数组
protected ChangeListener createChangeListener()
ChangeEvents
可以重写此返回另一个
ChangeListener
实施。
ChangeListener
protected void fireActionPerformed(ActionEvent event)
event
参数。
event
-
ActionEvent
对象
EventListenerList
protected void fireItemStateChanged(ItemEvent event)
event
参数。
event
-
ItemEvent
对象
EventListenerList
protected ActionListener createActionListener()
protected ItemListener createItemListener()
public void setEnabled(boolean b)
setEnabled
方法重写,继承类
JComponent
b
真使按钮,否则为false
Component.isEnabled()
,
Component.isLightweight()
@Deprecated public String getLabel()
getText
String
包含标签
@Deprecated public void setLabel(String label)
setText(text)
label
-
String
包含文本
public void addItemListener(ItemListener l)
ItemListener
的
checkbox
。
addItemListener
接口
ItemSelectable
l
-
ItemListener
加以补充
ItemEvent
public void removeItemListener(ItemListener l)
ItemListener
。
removeItemListener
接口
ItemSelectable
l
-
ItemListener
被删除
ItemEvent
public ItemListener[] getItemListeners()
ItemListener
s数组添加到这个abstractbutton与additemlistener()。
ItemListener
s说如果没有听众已添加一个空数组
public Object[] getSelectedObjects()
null
如果按钮未被选中。
getSelectedObjects
接口
ItemSelectable
null
public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h)
Icon
的
Image
不等于通过
Image
img
返回false。
imageUpdate
接口
ImageObserver
imageUpdate
方法重写,继承类
Component
img
-
Image
进行比较
infoflags
国旗用来粉刷按钮图像时更新并确定多少是画
x
的X坐标
y
的Y坐标
w
-宽度
h
-高度
false
如果infoflags表明图像完全加载;
true
否则。
ImageObserver
,
Component.imageUpdate(java.awt.Image, int, int, int, int, int)
protected String paramString()
AbstractButton
字符串表示形式。此方法仅用于调试目的,返回的字符串的内容和格式可能会在实现过程中有所不同。返回的字符串是空的但可能不
null
。
最重要的paramString
提供关于JFC组件的特定的新方面的信息。
paramString
方法重写,继承类
JComponent
AbstractButton
字符串表示形式
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.