- すべての実装されたインタフェース:
- ImageObserver,- MenuContainer,- Serializable,- Accessible
Quitボタンの3つのビューを表します。 
 
  
 
1番目のビューは通常の状態のボタンを示します。 2番目のビューは入力フォーカスがあるときのボタンを示します。 ボタンの輪郭は暗くなり、アクティブなオブジェクトであることをユーザーに示します。 3番目のビューは、ユーザーがボタンの上でマウスをクリックし、アクションの実行を要求したときのボタンを示します。
 マウスを使ってボタンをクリックするジェスチャは、マウスがボタン上で押されて離されたときに送信されるActionEventのインスタンスに関連付けられています。 いつボタンが押されたかを通知される必要はあっても、いつ離されたかを通知される必要がないアプリケーションの場合は、それらを独立したジェスチャとしてprocessMouseEventを特殊化したり、addMouseListenerを呼び出すことによりマウス・イベントのリスナーとして自身を登録したりできます。 これらのメソッドは両方とも、すべてのコンポーネントの抽象スーパー・クラスであるComponentによって定義されています。 
 
 ボタンが押されて離されると、AWTはボタンのprocessEventを呼び出すことにより、ボタンにActionEventのインスタンスを送ります。 ボタンのprocessEventメソッドはそのボタンのすべてのイベントを受け取ります。ボタンは自身のprocessActionEventメソッドを呼び出すことによってアクション・イベントを渡します。 後者のメソッドはこのボタンによって生成されるアクション・イベントの通知を対象として登録されているアクション・リスナーにアクション・イベントを渡します。 
 
 ボタン押されて離されることに基づいてアクションを実行するアプリケーションの場合は、addActionListenerを実装し、ボタンのActionListenerメソッドを呼び出すことにより、このボタンからイベントを受け取るように新しいリスナーを登録する必要があります。 アプリケーションはボタンのアクション・コマンドをメッセージ・プロトコルとして使用します。 
- 
ネストされたクラスのサマリーネストされたクラスクラス java.awt.Componentで宣言されたネストされたクラス/インタフェースComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
- 
フィールドのサマリークラス java.awt.Componentで宣言されたフィールドaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTインタフェース java.awt.image.ImageObserverで宣言されたフィールドABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
- 
コンストラクタのサマリーコンストラクタ
- 
メソッドのサマリー修飾子と型メソッド説明voidこのボタンからアクション・イベントを受け取るために、指定されたアクション・リスナーを追加します。voidボタンのピアを構築します。このButtonに関連付けられているAccessibleContextを取得します。このボタンでトリガーされるアクション・イベントのコマンド名を返します。このボタンに登録されたすべてのアクション・リスナーの配列を返します。getLabel()ボタンのラベルを取得します。<T extends EventListener>
 T[]getListeners(Class<T> listenerType)このButtonにFooListenerとして現在登録されているすべてのオブジェクトの配列を返します。protected StringこのButtonの状態を表す文字列を返します。protected voidこのボタンで発生するアクション・イベントを、登録されているActionListenerオブジェクトにディスパッチすることによって処理します。protected voidprocessEvent(AWTEvent e)このボタンのイベントを処理します。void以降このボタンからアクション・イベントを受け取らないように、指定されたアクション・リスナーを削除します。voidsetActionCommand(String command)このボタンによってトリガーされるアクション・イベントのコマンド名を設定します。voidボタンのラベルを、指定された文字列に設定します。クラス java.awt.Componentで宣言されたメソッドaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
- 
コンストラクタの詳細- 
ボタンpublic Button() throws HeadlessExceptionそのラベルの空の文字列を持つボタンを構築します。- 例外:
- HeadlessException- GraphicsEnvironment.isHeadless()がtrueを返す場合
- 関連項目:
- GraphicsEnvironment.isHeadless()
 
- 
ボタンpublic Button(String label) throws HeadlessException指定されたラベルを持つボタンを構築します。- パラメータ:
- label- ボタンの文字列ラベル。ラベルがない場合は- null
- 例外:
- HeadlessException- GraphicsEnvironment.isHeadless()がtrueを返す場合
- 関連項目:
- GraphicsEnvironment.isHeadless()
 
 
- 
- 
メソッドの詳細- 
addNotifypublic void addNotify()ボタンのピアを構築します。 ボタンのピアは、アプリケーションが機能を変更せずにボタンの外観を変更できるようにします。- オーバーライド:
- addNotify、クラス:- Component
- 関連項目:
- Component.getToolkit()
 
- 
getLabelpublic String getLabel()ボタンのラベルを取得します。- 戻り値:
- ボタンのラベル。ボタンにラベルがない場合はnull
- 関連項目:
- setLabel(java.lang.String)
 
- 
setLabelpublic void setLabel(String label)ボタンのラベルを、指定された文字列に設定します。- パラメータ:
- label- 新しいラベル。ボタンにラベルがない場合は- null
- 関連項目:
- getLabel()
 
- 
setActionCommandpublic void setActionCommand(String command)このボタンによってトリガーされるアクション・イベントのコマンド名を設定します。 デフォルトでは、このアクション・コマンドはボタンのラベルと一致するように設定されます。- パラメータ:
- command- ボタンのアクション・コマンドを設定するために使用する文字列。 文字列が- nullの場合、アクション・コマンドはボタンのラベルと一致するように設定される
- 導入されたバージョン:
- 1.1
- 関連項目:
- ActionEvent
 
- 
getActionCommandpublic String getActionCommand()このボタンでトリガーされるアクション・イベントのコマンド名を返します。 コマンド名がnull(デフォルト)の場合、このメソッドはボタンのラベルを返します。- 戻り値:
- このボタンのアクション・コマンド名(またはラベル)
 
- 
addActionListenerpublic void addActionListener(ActionListener l)このボタンからアクション・イベントを受け取るために、指定されたアクション・リスナーを追加します。 アクション・イベントは、ユーザーがこのボタンの上でマウス・ボタンを押したり、離したりしたときに発生します。 lがnullの場合、例外はスローされず、処理も実行されません。AWTスレッド・モデルの詳細は、「AWTのスレッドの問題」を参照してください。 - パラメータ:
- l- アクション・リスナー
- 導入されたバージョン:
- 1.1
- 関連項目:
- removeActionListener(java.awt.event.ActionListener),- getActionListeners(),- ActionListener
 
- 
removeActionListenerpublic void removeActionListener(ActionListener l)以降このボタンからアクション・イベントを受け取らないように、指定されたアクション・リスナーを削除します。 アクション・イベントは、ユーザーがこのボタンの上でマウス・ボタンを押したり、離したりしたときに発生します。 lがnullの場合、例外はスローされず、処理も実行されません。AWTスレッド・モデルの詳細は、「AWTのスレッドの問題」を参照してください。 - パラメータ:
- l- アクション・リスナー
- 導入されたバージョン:
- 1.1
- 関連項目:
- addActionListener(java.awt.event.ActionListener),- getActionListeners(),- ActionListener
 
- 
getActionListenerspublic ActionListener[] getActionListeners()このボタンに登録されたすべてのアクション・リスナーの配列を返します。- 戻り値:
- このボタンのすべてのActionListener。アクション・リスナーが現在登録されていない場合は空の配列
- 導入されたバージョン:
- 1.4
- 関連項目:
- addActionListener(java.awt.event.ActionListener),- removeActionListener(java.awt.event.ActionListener),- ActionListener
 
- 
getListenerspublic <T extends EventListener> T[] getListeners(Class<T> listenerType)このButtonにFooListenerとして現在登録されているすべてのオブジェクトの配列を返します。FooListenerは、addFooListenerメソッドを使用して登録されます。FooListener.classなどのクラス・リテラルを使用してlistenerType引数を指定できます。 たとえば、次のコードを使用して、Button bのアクション・リスナーを照会できます。ActionListener[] als = (ActionListener[])(b.getListeners(ActionListener.class)); このようなリスナーがない場合は空の配列を返します。- オーバーライド:
- getListeners、クラス:- Component
- 型パラメータ:
- T- リスナーの型
- パラメータ:
- listenerType- 要求されるリスナーの型。次の下位インタフェースを指定:- java.util.EventListener
- 戻り値:
- このボタン上でFooListenerとして登録されたすべてのオブジェクトの配列、またはこのようなリスナーが追加されていない場合は空の配列
- 例外:
- ClassCastException-- listenerTypeで、- java.util.EventListenerを実装するクラスまたはインタフェースが指定されなかった場合
- 導入されたバージョン:
- 1.3
- 関連項目:
- getActionListeners()
 
- 
processEventprotected void processEvent(AWTEvent e)このボタンのイベントを処理します。 イベントがActionEventのインスタンスである場合、このメソッドはprocessActionEventメソッドを呼び出します。 それ以外の場合は、スーパー・クラスのprocessEventを呼び出します。イベント・パラメータが nullである場合は、動作が未指定のため、例外が発生する可能性があります。- オーバーライド:
- processEvent、クラス:- Component
- パラメータ:
- e- イベント
- 導入されたバージョン:
- 1.1
- 関連項目:
- ActionEvent,- processActionEvent(java.awt.event.ActionEvent)
 
- 
processActionEventprotected void processActionEvent(ActionEvent e)このボタンで発生するアクション・イベントを、登録されているActionListenerオブジェクトにディスパッチすることによって処理します。このボタンに対してアクション・イベントが使用可能でない場合、このメソッドは呼び出されません。 アクション・イベントは、次のどちらかの場合に使用可能になります。 - ActionListenerオブジェクトが- addActionListenerによって登録されている。
- enableEventsによってアクション・イベントが使用可能になっている。
 イベント・パラメータが nullである場合は、動作が未指定のため、例外が発生する可能性があります。- パラメータ:
- e- アクション・イベント
- 導入されたバージョン:
- 1.1
- 関連項目:
- ActionListener,- addActionListener(java.awt.event.ActionListener),- Component.enableEvents(long)
 
- 
paramStringprotected String paramString()このButtonの状態を表す文字列を返します。 このメソッドはデバッグ専用であり、返される文字列の内容および形式は実装によって異なる可能性があります。 返される文字列は空でもかまいませんが、nullにはできません。- オーバーライド:
- paramString、クラス:- Component
- 戻り値:
- このボタンのパラメータ文字列
 
- 
getAccessibleContext@BeanProperty(expert=true, description="The AccessibleContext associated with this Button.") public AccessibleContext getAccessibleContext()このButtonに関連付けられているAccessibleContextを取得します。 ボタンの場合、AccessibleContextはAccessibleAWTButtonの形式を取ります。 必要に応じて、新しいAccessibleAWTButtonインスタンスが作成されます。- 定義:
- getAccessibleContext、インタフェース:- Accessible
- オーバーライド:
- getAccessibleContext、クラス:- Component
- 戻り値:
- このButtonのAccessibleContextとして機能するAccessibleAWTButton
- 導入されたバージョン:
- 1.3
 
 
-