public abstract class AbstractButton extends JComponent implements ItemSelectable, SwingConstants
ボタンは構成可能で、Action を使ってある程度まで制御できます。ボタンに対して Action を使用すると、直接ボタンを構成するよりも多くの利点があります。詳細は、「Action をサポートする Swing コンポーネント」を参照してください。また、『The Java Tutorial』の「How to Use Actions」も参照してください。
詳細は、『The Java Tutorial』の「How to Use Buttons, Check Boxes, and Radio Buttons」を参照してください。
警告: このクラスの直列化されたオブジェクトは、今後の Swing リリースと互換ではなくなる予定です。現在の直列化のサポートは、短期間の格納や、同じバージョンの Swing を実行するアプリケーション間の RMI に適しています。1.4 以降、すべての JavaBeansTM 用の長期間の格納サポートが java.beans パッケージに追加されています。XMLEncoder を参照してください。
| 修飾子と型 | クラスと説明 |
|---|---|
protected class |
AbstractButton.AccessibleAbstractButton
このクラスは
AbstractButton クラスのアクセシビリティーサポートを実装しています。 |
protected class |
AbstractButton.ButtonChangeListener
ChangeListener を拡張して、直列化できるようにします。 |
JComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy| 修飾子と型 | フィールドと説明 |
|---|---|
protected ActionListener |
actionListener
ボタンモデルの
ActionListener。 |
static String |
BORDER_PAINTED_CHANGED_PROPERTY
ボーダーが描画されるかどうかの変更を識別します。
|
protected ChangeEvent |
changeEvent
ChangeEvent の唯一の状態はソースプロパティーなので、ボタンの各インスタンスに必要なこのイベントは 1 つだけです。 |
protected ChangeListener |
changeListener
ボタンモデルの
changeListener。 |
static String |
CONTENT_AREA_FILLED_CHANGED_PROPERTY
ボタンのコンテンツ領域が塗りつぶされるかどうかについての変更を識別します。
|
static String |
DISABLED_ICON_CHANGED_PROPERTY
ボタンが無効のときに使用されるアイコンの変更を識別します。
|
static String |
DISABLED_SELECTED_ICON_CHANGED_PROPERTY
ボタンが無効で、選択されているときに使用されるアイコンの変更を識別します。
|
static String |
FOCUS_PAINTED_CHANGED_PROPERTY
フォーカスのあるときにボーダーがハイライト表示されるかどうかの変更を識別します。
|
static String |
HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY
ボタンの水平方向の配置の変更を識別します。
|
static String |
HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY
ボタンの水平方向のテキスト位置の変更を識別します。
|
static String |
ICON_CHANGED_PROPERTY
ボタンを表すアイコンの変更を識別します。
|
protected ItemListener |
itemListener
ボタンモデルの
ItemListener。 |
static String |
MARGIN_CHANGED_PROPERTY
ボタンのマージンの変更を識別します。
|
static String |
MNEMONIC_CHANGED_PROPERTY
ボタンのニーモニックの変更を識別します。
|
protected ButtonModel |
model
ボタンの状態を決定するデータモデルです。
|
static String |
MODEL_CHANGED_PROPERTY
ボタンモデルの変更を識別します。
|
static String |
PRESSED_ICON_CHANGED_PROPERTY
ボタンが押されたときに使用されるアイコンの変更を識別します。
|
static String |
ROLLOVER_ENABLED_CHANGED_PROPERTY
反転状態の有効から無効、または無効から有効への変更を識別します。
|
static String |
ROLLOVER_ICON_CHANGED_PROPERTY
カーソルがボタン上にあるときに使用されるアイコンの変更を識別します。
|
static String |
ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY
カーソルがボタン上にある場合に、ボタンが選択されたときに使用されるアイコンの変更を識別します。
|
static String |
SELECTED_ICON_CHANGED_PROPERTY
ボタンが選択されているときに使用されるアイコンの変更を識別します。
|
static String |
TEXT_CHANGED_PROPERTY
ボタンのテキストの変更を識別します。
|
static String |
VERTICAL_ALIGNMENT_CHANGED_PROPERTY
ボタンの垂直方向の配置の変更を識別します。
|
static String |
VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
ボタンの垂直方向のテキスト位置の変更を識別します。
|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWBOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTBOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WESTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| コンストラクタと説明 |
|---|
AbstractButton() |
| 修飾子と型 | メソッドと説明 |
|---|---|
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)
checkbox に ItemListener を追加します。 |
protected int |
checkHorizontalKey(int key, String exception)
horizontalAlignment プロパティーと horizontalTextPosition プロパティーに対して key 引数が正当な値であるかどうかを判定します。 |
protected int |
checkVerticalKey(int key, String exception)
key 引数が垂直方向のプロパティーにとって正当な値であるかどうかを判定します。 |
protected void |
configurePropertiesFromAction(Action a)
指定された
Action のプロパティーに一致するように、このボタンにプロパティーを設定します。 |
protected ActionListener |
createActionListener() |
protected PropertyChangeListener |
createActionPropertyChangeListener(Action a)
指定された
Action からの変更を待機し、適切なプロパティーを更新する役割を担う PropertyChangeListener を作成して、返します。 |
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 を返します。Action が設定されていない場合は、null を返します。 |
String |
getActionCommand()
ボタンのアクションコマンドを返します。
|
ActionListener[] |
getActionListeners()
addActionListener() を使用してこの AbstractButton に追加されたすべての
ActionListener の配列を返します。 |
ChangeListener[] |
getChangeListeners()
addChangeListener() でこの AbstractButton に追加される、すべての
ChangeListener の配列を返します。 |
Icon |
getDisabledIcon()
無効な状態のボタンのアイコンを返します。
|
Icon |
getDisabledSelectedIcon()
無効で、かつ選択されている状態のボタンのアイコンを返します。
|
int |
getDisplayedMnemonicIndex()
Look & Feel がニーモニック文字を表すための修飾を提供する文字をインデックスとして返します。
|
boolean |
getHideActionText()
ボタンが
Action からテキストを表示するかどうかを決定する、hideActionText プロパティーの値を返します。 |
int |
getHorizontalAlignment()
アイコンとテキストの水平方向の配置を返します。
|
int |
getHorizontalTextPosition()
アイコンに対するテキストの位置 (水平方向) を返します。
|
Icon |
getIcon()
デフォルトのアイコンを返します。
|
int |
getIconTextGap()
このボタンに表示されているテキストとアイコンとの距離を返します。
|
ItemListener[] |
getItemListeners()
addItemListener() でこの AbstractButton に追加される、すべての
ItemListener の配列を返します。 |
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)
ニーモニックを表すためにテキストのどの文字を装飾するかについてのヒントを、Look & Feel に提供します。
|
void |
setEnabled(boolean b)
ボタンを有効 (または無効) にします。
|
void |
setFocusPainted(boolean b)
paintFocus プロパティーを設定します。フォーカス状態をペイントするためには、このプロパティーが true である必要があります。 |
void |
setHideActionText(boolean hideActionText)
ボタンが
Action からテキストを表示するかどうかを決定する、hideActionText プロパティーを設定します。 |
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()
現在の Look & Feel からの値に UI プロパティーをリセットします。
|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, 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, updateadd, 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, validateTreeaction, 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, 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, transferFocusUpCyclepublic 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 の唯一の状態はソースプロパティーなので、ボタンの各インスタンスに必要なこのイベントは 1 つだけです。生成されるイベントのソースは、常に this です。public void setHideActionText(boolean hideActionText)
Action からテキストを表示するかどうかを決定する、hideActionText プロパティーを設定します。これは、ボタンに Action がインストールされている場合にのみ使用できます。hideActionText - ボタンの text プロパティーが Action のプロパティーを反映しない場合は true。デフォルトは falseAction をサポートする Swing コンポーネントpublic boolean getHideActionText()
Action からテキストを表示するかどうかを決定する、hideActionText プロパティーの値を返します。これは、ボタンに Action がインストールされている場合にのみ使用できます。text プロパティーが Action のプロパティーを反映しない場合は true。デフォルトは falsepublic String getText()
setText(java.lang.String)public boolean isSelected()
public void setSelected(boolean b)
actionEvent をトリガーしない点に注意してください。プログラム上で動作を変更するには、doClick を呼び出します。b - ボタンが選択されている場合は true、そうでない場合は falsepublic 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()
IconsetIcon(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()
Look & Feel によっては無効な状態のアイコンがレンダリングされないことがあり、その場合、無効な状態のアイコンは無視されます。
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() が呼び出されます。
Look & Feel によっては、無効で、かつ選択されている状態のアイコンがレンダリングされないことがあり、その場合、これは無視されます。
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)
horizontalAlignment プロパティーと horizontalTextPosition プロパティーに対して key 引数が正当な値であるかどうかを判定します。有効な値は次のとおりです。
SwingConstants.RIGHT
SwingConstants.LEFT
SwingConstants.CENTER
SwingConstants.LEADING
SwingConstants.TRAILING
key - チェックするプロパティー値exception - 値が無効である場合にスローされる IllegalArgumentException で使用されるメッセージIllegalArgumentException - キーが前述の正当な値のリストにない場合setHorizontalTextPosition(int), setHorizontalAlignment(int)protected int checkVerticalKey(int key,
String exception)
key 引数が垂直方向のプロパティーにとって正当な値であるかどうかを判定します。有効な値は次のとおりです。
SwingConstants.CENTER
SwingConstants.TOP
SwingConstants.BOTTOM
key - チェックするプロパティー値exception - 値が無効である場合にスローされる IllegalArgumentException で使用されるメッセージIllegalArgumentException - キーが前述の正当な値のリストにない場合public void removeNotify()
KeyboardAction が削除されます。このメソッドは、ツールキットによって内部的に呼び出されます。プログラムによって直接呼び出すべきではありません。removeNotify 、クラス: JComponentJComponent.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 である場合、再登録されません。
Action を設定すると、「Action をサポートする Swing コンポーネント」で説明されているすべてのプロパティーがすぐに変更されます。続いて、Action のプロパティーの変更に合わせて、ボタンのプロパティーが自動的に更新されます。
このメソッドは、Action のプロパティー値を設定し、追跡するために、ほかの 3 つのメソッドを使用します。このメソッドは、ボタンのプロパティーをただちに変更するために、configurePropertiesFromAction メソッドを使用します。Action のプロパティー値の変更を追跡するために、このメソッドは createActionPropertyChangeListener から返される PropertyChangeListener を登録します。デフォルトの PropertyChangeListener は、Action のプロパティーに変更があると、actionPropertyChanged メソッドを呼び出します。
a - AbstractButton の Action、または nullAction, getAction(), configurePropertiesFromAction(javax.swing.Action), createActionPropertyChangeListener(javax.swing.Action), actionPropertyChanged(javax.swing.Action, java.lang.String)public Action getAction()
ActionEvent ソースに現在設定されている Action を返します。Action が設定されていない場合は、null を返します。ActionEvent ソースの Action、または nullAction, setAction(javax.swing.Action)protected void configurePropertiesFromAction(Action a)
Action のプロパティーに一致するように、このボタンにプロパティーを設定します。これによって設定されるプロパティーの詳細は、「Action をサポートする Swing コンポーネント」を参照してください。a - プロパティーを取得する Action、または nullAction, setAction(javax.swing.Action)protected void actionPropertyChanged(Action action, String propertyName)
createActionPropertyChangeListener から返される PropertyChangeListener から呼び出されます。サブクラスは、通常、これを呼び出す必要はありません。追加の Action プロパティーをサポートするサブクラスは、これと configurePropertiesFromAction をオーバーライドする必要があります。
このメソッドによって設定されるプロパティーのリストは、「Action をサポートする Swing コンポーネント」の表を参照してください。
action - このボタンに関連付けられた ActionpropertyName - 変更されたプロパティーの名前Action, configurePropertiesFromAction(javax.swing.Action)protected PropertyChangeListener createActionPropertyChangeListener(Action a)
Action からの変更を待機し、適切なプロパティーを更新する役割を担う PropertyChangeListener を作成して、返します。
警告: これをサブクラス化する場合、匿名の内部クラスは作成しないでください。作成すると、ボタンの寿命が Action の寿命に拘束されます。
a - ボタンのアクションAction, setAction(javax.swing.Action)public boolean isBorderPainted()
borderPainted プロパティーを取得します。borderPainted プロパティーの値setBorderPainted(boolean)public void setBorderPainted(boolean b)
borderPainted プロパティーを設定します。true でボタンがボーダーを持つ場合は、ボーダーがペイントされます。borderPainted プロパティーのデフォルト値は true です。
Look & Feel によっては borderPainted プロパティーがサポートされない場合があり、その場合、これは無視されます。b - true であり、ボーダーのプロパティーが null でない場合、ボーダーをペイントするisBorderPainted()protected void paintBorder(Graphics g)
BorderPainted プロパティーが true であり、ボタンがボーダーを持つ場合、ボタンのボーダーをペイントします。paintBorder 、クラス: JComponentg - ペイント対象の 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 です。Look & Feel によってはフォーカス状態がペイントされないことがあり、その場合このプロパティーは無視されます。b - true の場合、フォーカス状態をペイントするisFocusPainted()public boolean isContentAreaFilled()
contentAreaFilled プロパティーを取得します。contentAreaFilled プロパティーsetContentAreaFilled(boolean)public void setContentAreaFilled(boolean b)
contentAreaFilled プロパティーを設定します。true の場合、ボタンのコンテンツ領域がペイントされます。たとえばアイコンだけのボタンのように、透過ボタンにする場合は false に設定するようにしてください。setOpaque(false) の呼び出しは行いません。contentAreaFilled プロパティーのデフォルト値は true です。
この関数は、コンポーネントの透過プロパティーを変更する可能性があります。
この関数を呼び出した場合の正確な動作は、コンポーネントおよび Look & Feel により異なります。
b - true の場合はコンテンツが塗りつぶされ、false の場合はコンテンツ領域は塗りつぶされないisContentAreaFilled(), JComponent.setOpaque(boolean)public boolean isRolloverEnabled()
rolloverEnabled プロパティーを取得します。rolloverEnabled プロパティーの値setRolloverEnabled(boolean)public void setRolloverEnabled(boolean b)
rolloverEnabled プロパティーを設定します。反転の効果をペイントするためには、このプロパティーが true である必要があります。rolloverEnabled プロパティーのデフォルト値は false です。Look & Feel によっては反転の効果がペイントされないことがあり、その場合このプロパティーは無視されます。b - true の場合、反転の効果をペイントするisRolloverEnabled()public int getMnemonic()
public void setMnemonic(int mnemonic)
ニーモニックはキーボード上の 1 つのキーに対応している必要があり、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」を持つテキスト「Save As」について、「Save As」のように A を修飾する場合は、setMnemonic(KeyEvent.VK_A) を呼び出してから setDisplayedMnemonicIndex(5) を呼び出します。
index - 下線を付ける String に対するインデックス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 - 新しい ButtonModelgetModel()public ButtonUI getUI()
setUI(javax.swing.plaf.ButtonUI)public void setUI(ButtonUI ui)
ui - ButtonUI L&F オブジェクトgetUI()public void updateUI()
AbstractButton のサブタイプでこれをオーバーライドし、UI を更新します。例として次に JButton を挙げます。
setUI((ButtonUI)UIManager.getUI(
"ButtonUI", "javax.swing.plaf.basic.BasicButtonUI", this));
protected void addImpl(Component comp, Object constraints, int index)
Container.addImpl(Component, Object, int) を参照してください。addImpl 、クラス: Containercomp - 追加されるコンポーネントconstraints - このコンポーネントのレイアウト制約を表現するオブジェクトindex - コンポーネントを挿入するコンテナのリスト内での位置。-1 は最後に挿入することを意味するIllegalArgumentException - index が無効である場合IllegalArgumentException - コンテナの親をそのコンテナ自体に追加しようとしている場合IllegalArgumentException - ウィンドウをコンテナに追加しようとしている場合Container.add(Component), Container.add(Component, int), Container.add(Component, java.lang.Object), Container.invalidate(), LayoutManager, LayoutManager2public void setLayout(LayoutManager mgr)
Container.setLayout(LayoutManager) を参照してください。setLayout 、クラス: Containermgr - 指定されたレイアウトマネージャーContainer.doLayout(), Container.getLayout(), Container.invalidate()public void addChangeListener(ChangeListener l)
ChangeListener を追加します。l - 追加されるリスナーpublic void removeChangeListener(ChangeListener l)
l - 削除されるリスナーpublic ChangeListener[] getChangeListeners()
ChangeListener の配列を返します。ChangeListener。リスナーが追加されていない場合は空の配列protected void fireStateChanged()
EventListenerListpublic void addActionListener(ActionListener l)
ActionListener を追加します。l - 追加される ActionListenerpublic void removeActionListener(ActionListener l)
ActionListener を削除します。リスナーがボタンに現在設定されている Action の場合、Action は null に設定されます。l - 削除されるリスナーpublic ActionListener[] getActionListeners()
ActionListener の配列を返します。ActionListener。リスナーが追加されていない場合は空の配列protected ChangeListener createChangeListener()
ChangeEvents を処理する場合は、このメソッドをオーバーライドして別の ChangeListener の実装を返すことができます。ChangeListenerprotected void fireActionPerformed(ActionEvent event)
event パラメータで遅延生成されます。event - ActionEvent オブジェクトEventListenerListprotected void fireItemStateChanged(ItemEvent event)
event パラメータで遅延生成されます。event - ItemEvent オブジェクトEventListenerListprotected ActionListener createActionListener()
protected ItemListener createItemListener()
public void setEnabled(boolean b)
setEnabled 、クラス: JComponentb - ボタンを有効にする場合は true、そうでない場合は falseComponent.isEnabled(), Component.isLightweight()@Deprecated public String getLabel()
getText に置き換えられています。String@Deprecated public void setLabel(String label)
setText(text) に置き換えられていますlabel - テキストが格納されている Stringpublic void addItemListener(ItemListener l)
checkbox に ItemListener を追加します。addItemListener 、インタフェース: ItemSelectablel - 追加される ItemListenerItemEventpublic void removeItemListener(ItemListener l)
ItemListener を削除します。removeItemListener 、インタフェース: ItemSelectablel - 削除する ItemListenerItemEventpublic ItemListener[] getItemListeners()
ItemListener の配列を返します。ItemListener。リスナーが追加されていない場合は空の配列public Object[] getSelectedObjects()
null を返します。getSelectedObjects 、インタフェース: ItemSelectablenullpublic boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h)
Icon の Image が、渡された Image img と異なる場合は、オーバーライドされて false を返します。imageUpdate 、インタフェース: ImageObserverimageUpdate 、クラス: Componentimg - 比較対象の Imageinfoflags - イメージが更新されたときにボタンの再ペイントに使用されるフラグ。どれだけペイントするかを判定するx - x 座標y - y 座標w - 幅h - 高さfalse、そうでない場合は true。ImageObserver、Component.imageUpdate(java.awt.Image, int, int, int, int, int)protected String paramString()
AbstractButton の文字列表現を返します。このメソッドはデバッグ専用であり、返される文字列の内容および形式は実装によって異なります。返される文字列は空の場合がありますが、null にはなりません。
JFC コンポーネントの特定の新しい側面についての情報を提供するには、paramString をオーバーライドします。
paramString 、クラス: JComponentAbstractButton の文字列表現 バグまたは機能を送信
詳細な API リファレンスおよび開発者ドキュメントについては、Java SE のドキュメントを参照してください。そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright © 1993, 2013, Oracle and/or its affiliates. All rights reserved.