JavaTM Platform
Standard Ed. 6

java.awt
클래스 Button

java.lang.Object 
  상위를 확장 java.awt.Component 
      상위를 확장 java.awt.Button
모든 구현된 인터페이스:
ImageObserver , MenuContainer , Serializable , Accessible


public class Button
extends Component
implements Accessible

이 클래스는 라벨 첨부 버튼을 생성합니다. 어플리케이션은, 버튼이 밀렸을 때에 액션이 실행되도록(듯이) 할 수가 있습니다. 이 이미지는, Solaris operating system로 표시되는 Quit 버튼의 3 개의 뷰를 나타냅니다.  

이하의 문맥으로 그림을 설명하는  

1 번째의 뷰는 일반적으로 상태의 버튼을 나타냅니다. 2 번째의 뷰는 입력초점이 있을 때의 버튼을 나타냅니다. 버튼의 윤곽은 어두워져, 액티브한 객체인 것을 사용자에게 나타냅니다. 3 번째의 뷰는, 사용자가 버튼 위에서 마우스를 클릭해, 액션의 실행을 요구했을 때의 버튼을 나타냅니다.  

마우스를 사용해 버튼을 클릭하는 제스처(gesture)는, 마우스가 버튼상에서 밀려 떼어 놓아졌을 때에 송신되는 ActionEvent 의 인스턴스에 관련지을 수 있고 있습니다. 언제 버튼이 밀렸는지의 통지는 필요하지만, 언제 떼어 놓아졌는지의 통지는 필요하지 않은 경우, 어플리케이션은, 독립한 동작으로서 processMouseEvent 를 특수화 하는 일도,addMouseListener 를 호출하는 것으로 마우스 이벤트의 청취자로서 자신을 등록할 수도 있습니다. 이러한 메소드는 양쪽 모두, 모든 컴퍼넌트의 추상 슈퍼 클래스인 Component 에 의해 정의됩니다.  

버튼이 밀려 떼어 놓아지면(자), AWT 는 버튼의 processEvent 를 호출하는 것으로, 버튼에 ActionEvent 의 인스턴스를 보냅니다. 버튼의 processEvent 메소드는 그 버튼의 모든 이벤트를 받습니다. 버튼은 자신의 processActionEvent 메소드를 호출하는 것에 의해 액션 이벤트를 건네줍니다. processActionEvent 메소드는 이 버튼에 의해 생성되는 액션 이벤트의 통지를 대상으로 해 등록되어 있는 액션 청취자에게 액션 이벤트를 건네줍니다.  

밀려 떼어 놓아지는 버튼에 근거해 액션을 실행하는 경우, 어플리케이션은,ActionListener 를 구현해, 버튼의 addActionListener 메소드를 호출하는 것으로, 이 버튼으로부터 이벤트를 받도록(듯이) 새로운 청취자를 등록할 필요가 있습니다. 어플리케이션은 버튼의 액션 커멘드를 메세지 프로토콜로서 사용합니다.

도입된 버젼:
JDK1. 0
관련 항목:
ActionEvent , ActionListener , Component.processMouseEvent(java.awt.event.MouseEvent) , Component.addMouseListener(java.awt.event.MouseListener) , 직렬화 된 형식

상자의 클래스의 개요
protected  class Button.AccessibleAWTButton
          이 클래스는 Button 클래스용의 사용자 보조 기능의 지원를 구현하고 있습니다.
 
클래스 java.awt. Component 로부터 상속된 상자의 클래스/인터페이스
Component.AccessibleAWTComponent , Component.BaselineResizeBehavior , Component.BltBufferStrategy , Component.FlipBufferStrategy
 
필드의 개요
 
클래스 java.awt. Component 로부터 상속된 필드
BOTTOM_ALIGNMENT , CENTER_ALIGNMENT , LEFT_ALIGNMENT , RIGHT_ALIGNMENT , TOP_ALIGNMENT
 
인터페이스 java.awt.image. ImageObserver 로부터 상속된 필드
ABORT , ALLBITS , ERROR , FRAMEBITS , HEIGHT , PROPERTIES , SOMEBITS , WIDTH
 
생성자 의 개요
Button ()
          그 라벨의 빈 상태(empty)의 캐릭터 라인을 가지는 버튼을 구축합니다.
Button (String  label)
          지정된 라벨을 가지는 버튼을 구축합니다.
 
메소드의 개요
 void addActionListener (ActionListener  l)
          이 버튼으로부터 액션 이벤트를 받기 위해서(때문에), 지정된 액션 청취자를 추가합니다.
 void addNotify ()
          버튼의 피어를 구축합니다.
 AccessibleContext getAccessibleContext ()
          이 Button 에 관련지을 수 있는 AccessibleContext 를 가져옵니다.
 String getActionCommand ()
          이 버튼으로 트리거되는 액션 이벤트의 커멘드명을 돌려줍니다.
 ActionListener [] getActionListeners ()
          이 버튼에 등록되어 모든 액션 청취자의 배열을 돌려줍니다.
 String getLabel ()
          버튼의 라벨을 돌려줍니다.
<T extends EventListener >
T[]
getListeners (Class <T> listenerType)
          이 ButtonFooListener 로서 현재 등록되어 모든 객체의 배열을 돌려줍니다.
protected  String paramString ()
          이 Button 상태를 나타내는 캐릭터 라인을 돌려줍니다.
protected  void processActionEvent (ActionEvent  e)
          이 버튼으로 발생하는 액션 이벤트를, 등록되어 있는 ActionListener 객체에 발송 하는 것으로써, 액션 이벤트를 처리합니다.
protected  void processEvent (AWTEvent  e)
          이 버튼에 관한 이벤트를 처리합니다.
 void removeActionListener (ActionListener  l)
          이 버튼으로부터 액션 이벤트를 받지 않게, 지정된 액션 청취자를 삭제합니다.
 void setActionCommand (String  command)
          이 버튼에 의해 트리거되는 액션 이벤트의 커멘드명을 설정합니다.
 void setLabel (String  label)
          버튼의 라벨을, 지정된 캐릭터 라인으로 설정합니다.
 
클래스 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 , getPeer , 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 , requestFocusInWindow , requestFocusInWindow , reshape , resize , resize , setBackground , setBounds , setBounds , setComponentOrientation , setCursor , setDropTarget , setEnabled , setFocusable , setFocusTraversalKeys , setFocusTraversalKeysEnabled , setFont , setForeground , setIgnoreRepaint , setLocale , setLocation , setLocation , setMaximumSize , setMinimumSize , setName , setPreferredSize , setSize , setSize , setVisible , show , show , size , toString , transferFocus , transferFocusBackward , transferFocusUpCycle , update , validate
 
클래스 java.lang. Object 로부터 상속된 메소드
clone , equals , finalize , getClass , hashCode , notify , notifyAll , wait , wait , wait
 

생성자 의 상세

Button

public Button()
       throws HeadlessException 
그 라벨의 빈 상태(empty)의 캐릭터 라인을 가지는 버튼을 구축합니다.

예외:
HeadlessException - GraphicsEnvironment.isHeadless()가 true 를 돌려주는 경우
관련 항목:
GraphicsEnvironment.isHeadless()

Button

public Button(String  label)
       throws HeadlessException 
지정된 라벨을 가지는 버튼을 구축합니다.

파라미터:
label - 버튼의 캐릭터 라인 라벨. 라벨이 없는 경우는 null
예외:
HeadlessException - GraphicsEnvironment.isHeadless()가 true 를 돌려주는 경우
관련 항목:
GraphicsEnvironment.isHeadless()
메소드의 상세

addNotify

public void addNotify()
버튼의 피어를 구축합니다. 버튼의 피어는, 어플리케이션이 기능을 변경하지 않고 버튼의 외관을 변경할 수 있도록(듯이) 합니다.

오버라이드(override):
클래스 Component 내의 addNotify
관련 항목:
Toolkit.createButton(java.awt.Button) , Component.getToolkit()

getLabel

public String  getLabel()
버튼의 라벨을 돌려줍니다.

반환값:
버튼의 라벨. 버튼에 라벨이 없는 경우는 null
관련 항목:
setLabel(java.lang.String)

setLabel

public void setLabel(String  label)
버튼의 라벨을, 지정된 캐릭터 라인으로 설정합니다.

파라미터:
label - 새로운 라벨. 버튼에 라벨이 없는 경우는 null
관련 항목:
getLabel()

setActionCommand

public void setActionCommand(String  command)
이 버튼에 의해 트리거되는 액션 이벤트의 커멘드명을 설정합니다. 디폴트에서는, 이 액션 커멘드는 버튼의 라벨과 일치하도록(듯이) 설정됩니다.

파라미터:
command - 버튼의 액션 커멘드 설정에 사용된다 캐릭터 라인. 캐릭터 라인이 null 의 경우, 액션 커멘드는 버튼의 라벨과 일치하도록(듯이) 설정되는
도입된 버젼:
JDK1. 1
관련 항목:
ActionEvent

getActionCommand

public String  getActionCommand()
이 버튼으로 트리거되는 액션 이벤트의 커멘드명을 돌려줍니다. 커멘드명이 null (디폴트)의 경우, 이 메소드는 버튼의 라벨을 돌려줍니다.


addActionListener

public void addActionListener(ActionListener  l)
이 버튼으로부터 액션 이벤트를 받기 위해서(때문에), 지정된 액션 청취자를 추가합니다. 액션 이벤트는, 사용자가 이 버튼 위에서 mouse button를 누르거나 떼어 놓거나 했을 때에 발생합니다. l 가 null 의 경우, 예외는 throw 되지 않고, 처리도 실행되지 않습니다.  

thread 모델의 자세한 것은,「AWT Threading Issues」를 참조해 주세요.

파라미터:
l - 액션 청취자
도입된 버젼:
JDK1. 1
관련 항목:
removeActionListener(java.awt.event.ActionListener) , getActionListeners() , ActionListener

removeActionListener

public void removeActionListener(ActionListener  l)
이 버튼으로부터 액션 이벤트를 받지 않게, 지정된 액션 청취자를 삭제합니다. 액션 이벤트는, 사용자가 이 버튼 위에서 mouse button를 누르거나 떼어 놓거나 했을 때에 발생합니다. l 가 null 의 경우, 예외는 throw 되지 않고, 처리도 실행되지 않습니다.  

thread 모델의 자세한 것은,「AWT Threading Issues」를 참조해 주세요.

파라미터:
l - 액션 청취자
도입된 버젼:
JDK1. 1
관련 항목:
addActionListener(java.awt.event.ActionListener) , getActionListeners() , ActionListener

getActionListeners

public ActionListener [] getActionListeners()
이 버튼에 등록되어 모든 액션 청취자의 배열을 돌려줍니다.

반환값:
이 버튼의 모든 ActionListener. 액션 청취자가 현재 등록되지 않은 경우는 빈 상태(empty)의 배열
도입된 버젼:
1.4
관련 항목:
addActionListener(java.awt.event.ActionListener) , removeActionListener(java.awt.event.ActionListener) , ActionListener

getListeners

public <T extends EventListener > T[] getListeners(Class <T> listenerType)
ButtonFooListener 로서 현재 등록되어 모든 객체의 배열을 돌려줍니다. FooListener 는,addFooListener 메소드를 사용해 등록합니다.

FooListener.class 라고 하는 클래스 리터럴을 사용해,listenerType 인수를 지정할 수 있습니다. 예를 들어, 이 액션 청취자에 대한 Button b 의 조회는 다음의 코드로 실시합니다. 이러한 청취자가 없는 경우는 빈 상태(empty)의 배열을 돌려줍니다.

오버라이드(override):
클래스 Component 내의 getListeners
파라미터:
listenerType - 요구되는 청취자의 형태. java.util.EventListener 의 하위 인터페이스를 지정
반환값:
이 컴퍼넌트에 FooListener 로서 등록되어 모든 객체의 배열. 이 버튼에 FooListener 로서 등록되어 모든 객체의 배열. 청취자가 등록되지 않은 경우는 빈 상태(empty)의 배열
예외:
ClassCastException - listenerTypejava.util.EventListener 를 구현하는 클래스 또는 인터페이스를 지정하지 않는 경우
도입된 버젼:
1.3
관련 항목:
getActionListeners()

processEvent

protected void processEvent(AWTEvent  e)
이 버튼에 관한 이벤트를 처리합니다. 이벤트가 ActionEvent 의 인스턴스인 경우, 이 메소드는 processActionEvent 메소드를 호출합니다. 그렇지 않은 경우는 슈퍼 클래스의 processEvent 를 호출합니다.  

이벤트 파라미터가 null 의 경우의 동작은 정의되어 있지 않기 때문에 예외가 throw 됩니다.

오버라이드(override):
클래스 Component 내의 processEvent
파라미터:
e - 이벤트
도입된 버젼:
JDK1. 1
관련 항목:
ActionEvent , processActionEvent(java.awt.event.ActionEvent)

processActionEvent

protected void processActionEvent(ActionEvent  e)
이 버튼으로 발생하는 액션 이벤트를, 등록되어 있는 ActionListener 객체에 발송 하는 것으로써, 액션 이벤트를 처리합니다.  

이 버튼에 대해서 액션 이벤트가 사용 가능하지 않은 경우, 이 메소드는 불려 가지 않습니다. 액션 이벤트는, 다음의 어느 쪽인가의 경우에 사용 가능하게 됩니다.

  • ActionListener 객체가 addActionListener 에 의해 등록되어 있다
  • enableEvents 에 의해 액션 이벤트가 사용 가능하게 되어 있다
 

이벤트 파라미터가 null 의 경우의 동작은 정의되어 있지 않기 때문에 예외가 throw 됩니다.

파라미터:
e - 액션 이벤트
도입된 버젼:
JDK1. 1
관련 항목:
ActionListener , addActionListener(java.awt.event.ActionListener) , Component.enableEvents(long)

paramString

protected String  paramString()
Button 상태를 나타내는 캐릭터 라인을 돌려줍니다. 이 메소드는 디버그 전용이며, 반환되는 캐릭터 라인의 내용 및 형식은 구현에 따라서 다릅니다. 반환되는 캐릭터 라인은 빈 상태(empty)의 경우가 있습니다만,null 로는 되지 않습니다.

오버라이드(override):
클래스 Component 내의 paramString
반환값:
이 버튼의 파라미터 캐릭터 라인

getAccessibleContext

public AccessibleContext  getAccessibleContext()
Button 에 관련지을 수 있는 AccessibleContext 를 가져옵니다. AccessibleContext 는 버튼의 폼을 AccessibleAWTButton 로부터 가져옵니다. 필요한 경우는 새로운 AccessibleAWTButton 인스턴스를 생성합니다.

정의:
인터페이스 Accessible 내의 getAccessibleContext
오버라이드(override):
클래스 Component 내의 getAccessibleContext
반환값:
ButtonAccessibleContext 로서 기능하는 AccessibleAWTButton
도입된 버젼:
1.3

JavaTM Platform
Standard Ed. 6

버그의 보고와 기능의 요청
한층 더 자세한 API 레퍼런스 및 개발자 문서에 대해서는,Java SE 개발자용 문서를 참조해 주세요. 개발자전용의 상세한 해설, 개념의 개요, 용어의 정의, 버그의 회피책, 및 코드 실례가 포함되어 있습니다.

Copyright 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms . Documentation Redistribution Policy 도 참조해 주세요.