JavaTM Platform
Standard Ed. 6

javax.swing
클래스 Box

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


public class Box
extends JComponent
implements Accessible

BoxLayout 객체를 레이아웃 매니저로서 사용하는 경량인 컨테이너입니다. Box 에는, BoxLayout 를 사용하는 컨테이너 또는 Box 가 아닌 컨테이너에도 편리한 클래스 메소드가 몇개인가 준비되어 있습니다.

Box 클래스는, 레이아웃에 영향을 주는 여러종류의 불가시 컴퍼넌트를 작성할 수 있습니다. 예를 들어, 접착제 (glue), 기둥 (strut), 및 고정 영역 (rigid area)입니다. Box 에 포함되는 모든 컴퍼넌트의 사이즈가 고정되고 있는 경우는,createGlue 가 돌려주는 접착제 컴퍼넌트를 사용해, 컴퍼넌트의 위치를 제어할 수 있습니다. 2 개의 컴퍼넌트의 사이에 일정한 공간이 필요한 경우는, 기둥을 사용해 보는 것을 추천합니다 (createHorizontalStrut 또는 createVerticalStrut). 항상 같은 양의 공간을 차지하는 불가시 컴퍼넌트가 필요한 경우는,createRigidArea 를 호출하는 것으로, 그 컴퍼넌트를 가져옵니다.

BoxLayout 를 구현하고 있는 경우, 상세한 정보와 예에 대해서는,「The Java Tutorial」「How to Use BoxLayout」를 참조해 주세요.

경고: 이 클래스의 직렬화 된 객체는, 향후의 Swing 릴리스와 호환은 아니게 될 예정입니다. 현재의 직렬화의 지원는, 단기간의 운용이나, 같은 버젼의 Swing 를 실행하는 어플리케이션간의 RMI 에 적절하고 있습니다. JDK Version 1.4 이후, 모든 JavaBeans 의 장기간의 운용 지원는,java.beans 패키지에 추가되고 있습니다. 자세한 것은,XMLEncoder 를 참조해 주세요.

관련 항목:
BoxLayout

상자의 클래스의 개요
protected  class Box.AccessibleBox
          이 클래스는 Box 클래스용의 사용자 보조 기능의 지원를 구현하고 있습니다.
static class Box.Filler
          배치에 포함되지만 뷰를 가지지 않는 경량 컴퍼넌트의 구현입니다.
 
클래스 javax.swing. JComponent 로부터 상속된 상자의 클래스/인터페이스
JComponent.AccessibleJComponent
 
클래스 java.awt. Container 로부터 상속된 상자의 클래스/인터페이스
Container.AccessibleAWTContainer
 
클래스 java.awt. Component 로부터 상속된 상자의 클래스/인터페이스
Component.AccessibleAWTComponent , Component.BaselineResizeBehavior , Component.BltBufferStrategy , Component.FlipBufferStrategy
 
필드의 개요
 
클래스 javax.swing. JComponent 로부터 상속된 필드
accessibleContext , listenerList , TOOL_TIP_TEXT_KEY , ui , UNDEFINED_CONDITION , WHEN_ANCESTOR_OF_FOCUSED_COMPONENT , WHEN_FOCUSED , WHEN_IN_FOCUSED_WINDOW
 
클래스 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
 
생성자 의 개요
Box (int axis)
          지정된 축으로 따라 컴퍼넌트를 표시하는 Box 를 생성합니다.
 
메소드의 개요
static Component createGlue ()
          불가시의 「접착제」컴퍼넌트를 작성합니다.
static Box createHorizontalBox ()
          컴퍼넌트를 왼쪽에서 오른쪽에 표시하는 Box 를 생성합니다.
static Component createHorizontalGlue ()
          수평 방향의 접착제 컴퍼넌트를 작성합니다.
static Component createHorizontalStrut (int width)
          불가시의 고정폭컴퍼넌트를 생성합니다.
static Component createRigidArea (Dimension  d)
          항상 지정된 사이즈인, 불가시 컴퍼넌트를 생성합니다.
static Box createVerticalBox ()
          컴퍼넌트를 위에서 밑으로 표시하는 Box 를 생성합니다.
static Component createVerticalGlue ()
          수직 방향의 접착제 컴퍼넌트를 작성합니다.
static Component createVerticalStrut (int height)
          불가시의, 높이가 고정된 컴퍼넌트를 작성합니다.
 AccessibleContext getAccessibleContext ()
          이 박스에 관련한 AccessibleContext 를 돌려줍니다.
protected  void paintComponent (Graphics  g)
          이 Box 를 그립니다.
 void setLayout (LayoutManager  l)
          AWTError 를 throw 합니다.
 
클래스 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 , isDoubleBuffered , isLightweightComponent , isManagingFocus , isOpaque , isOptimizedDrawingEnabled , isPaintingForPrint , isPaintingTile , isRequestFocusEnabled , isValidateRoot , paint , paintBorder , paintChildren , paintImmediately , paintImmediately , paramString , print , printAll , printBorder , printChildren , printComponent , processComponentKeyEvent , processKeyBinding , processKeyEvent , processMouseEvent , processMouseMotionEvent , putClientProperty , registerKeyboardAction , registerKeyboardAction , removeAncestorListener , removeNotify , removeVetoableChangeListener , repaint , repaint , requestDefaultFocus , requestFocus , requestFocus , requestFocusInWindow , requestFocusInWindow , resetKeyboardActions , reshape , revalidate , scrollRectToVisible , setActionMap , setAlignmentX , setAlignmentY , setAutoscrolls , setBackground , setBorder , setComponentPopupMenu , setDebugGraphicsOptions , setDefaultLocale , setDoubleBuffered , setEnabled , setFocusTraversalKeys , setFont , setForeground , setInheritsPopupMenu , setInputMap , setInputVerifier , setMaximumSize , setMinimumSize , setNextFocusableComponent , setOpaque , setPreferredSize , setRequestFocusEnabled , setToolTipText , setTransferHandler , setUI , setVerifyInputWhenFocusTarget , setVisible , unregisterKeyboardAction , update , updateUI
 
클래스 java.awt. Container 로부터 상속된 메소드
add , add , add , add , add , addContainerListener , addImpl , 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 , transferFocusBackward , transferFocusDownCycle , validate , validateTree
 
클래스 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 , 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 , hide , imageUpdate , 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 , transferFocusUpCycle
 
클래스 java.lang. Object 로부터 상속된 메소드
clone , equals , finalize , getClass , hashCode , notify , notifyAll , wait , wait , wait
 

생성자 의 상세

Box

public Box(int axis)
지정된 축으로 따라 컴퍼넌트를 표시하는 Box 를 생성합니다.

파라미터:
axis - BoxLayout.X_AXIS , BoxLayout.Y_AXIS , BoxLayout.LINE_AXIS , 또는 BoxLayout.PAGE_AXIS .
예외:
AWTError - axis 가 무효인 경우
관련 항목:
createHorizontalBox() , createVerticalBox()
메소드의 상세

createHorizontalBox

public static Box  createHorizontalBox()
컴퍼넌트를 왼쪽에서 오른쪽에 표시하는 Box 를 생성합니다. 컴퍼넌트의 방향을 고려한 Box 가 필요한 경우는, 생성자 을 사용해 Box 를 생성해,BoxLayout.LINE_AXIS 에 건네줄 필요가 있습니다. 다음에 예를 나타냅니다.
   Box lineBox = new Box(BoxLayout.LINE_AXIS);
 

반환값:
박스

createVerticalBox

public static Box  createVerticalBox()
컴퍼넌트를 위에서 밑으로 표시하는 Box 를 생성합니다. 컴퍼넌트의 방향을 고려한 Box 가 필요한 경우는, 생성자 을 사용해 Box 를 생성해,BoxLayout.PAGE_AXIS 에 건네줄 필요가 있습니다. 다음에 예를 나타냅니다.
   Box lineBox = new Box(BoxLayout.PAGE_AXIS);
 

반환값:
박스

createRigidArea

public static Component  createRigidArea(Dimension  d)
항상 지정된 사이즈인, 불가시 컴퍼넌트를 생성합니다.

파라미터:
d - 불가시 컴퍼넌트의 사이즈
반환값:
컴퍼넌트
관련 항목:
createGlue() , createHorizontalStrut(int) , createVerticalStrut(int)

createHorizontalStrut

public static Component  createHorizontalStrut(int width)
불가시의 고정폭컴퍼넌트를 생성합니다. 수평 박스에서는, 이 메소드를 사용해, 2 개의 컴퍼넌트의 간격을 고정할 수 있습니다. 수직 박스에서는, 이 메소드를 사용해, 박스의 폭을 지정할 수 있습니다. 불가시 컴퍼넌트는, 공간이 남지 않은 한 높이가 없습니다. 공간이 남아 있으면, 높이의 최대치의 지정이 없는 컴퍼넌트와 같게, 자신에게 필요한 분의 공간을 차지합니다.

파라미터:
width - 불가시 컴퍼넌트의 픽셀 단위의 폭. 값은 제로 이상
반환값:
컴퍼넌트
관련 항목:
createVerticalStrut(int) , createGlue() , createRigidArea(java.awt.Dimension)

createVerticalStrut

public static Component  createVerticalStrut(int height)
불가시의, 높이가 고정된 컴퍼넌트를 작성합니다. 수직 박스에서는, 이 메소드를 사용해, 2 개의 컴퍼넌트의 간격을 고정할 수 있습니다. 수평 박스에서는, 이 메소드를 사용해, 박스의 폭을 지정할 수 있습니다. 불가시 컴퍼넌트는, 공간이 남지 않은 한 폭이 없습니다. 공간이 남아 있으면, 폭의 최대치의 지정이 없는 컴퍼넌트와 같게, 자신에게 필요한 분의 공간을 차지합니다.

파라미터:
height - 불가시 컴퍼넌트의 픽셀 단위의 높이. 값은 제로 이상
반환값:
컴퍼넌트
관련 항목:
createHorizontalStrut(int) , createGlue() , createRigidArea(java.awt.Dimension)

createGlue

public static Component  createGlue()
불가시의 「접착제」컴퍼넌트를 작성합니다. 이것은, 가시 컴퍼넌트에 수평 박스에 대한 최대폭이나 수직 박스에 대한 최대고가 지정되고 있는 Box 에 편리합니다. 접착제 컴퍼넌트는, 서로 이웃이 되는 컴퍼넌트의 간격을 묻기 위해서(때문에) 필요한 만큼 늘어나는, 풀과 같은 것이라고 생각할 수가 있습니다.

예를 들어, 1 개의 수평 박스에, 고정 사이즈의 컴퍼넌트가 2 개 포함되어 있다고 합니다. 이 박스에 공간이 추가되어도, 고정 사이즈 컴퍼넌트는 커지지 않습니다. 이 때, 접착제가 없는 경우, 2 번째의 컴퍼넌트의 오른쪽의 공간이 남습니다. 여기서 접착제를 고정 사이즈 컴퍼넌트의 사이에 두면(자), 남은 공간을 접착제 컴퍼넌트가 차지합니다. 접착제를 1 번째의 고정 사이즈 컴퍼넌트의 전에 두면(자), 남은 공간을 접착제 컴퍼넌트가 차지해 2 개의 고정 사이즈 컴퍼넌트는 박스의 오른쪽으로 전해집니다. 1 번째의 고정 사이즈 컴퍼넌트의 전, 및 2 번째의 고정 사이즈 컴퍼넌트의 후에 접착제를 두면(자), 2 개의 고정 사이즈 컴퍼넌트는 박스의 중앙에 전해집니다.

접착제를 사용하려면 ,Box.createGlue 를 호출해, 반환된 컴퍼넌트를 컨테이너에 추가합니다. 접착제 컴퍼넌트에는, 최소의 사이즈, 혹은 적절한 사이즈가 없습니다. 그 때문에, 여분의 공간이 없는 한, 공간을 차지할 것은 없습니다. 여분의 공간이 있으면, 접착제 컴퍼넌트는, 수평 방향, 또는 수직 방향의 이용 가능한 공간을 차지합니다. 이것은, 폭 혹은 높이의 최대치의 지정이 없는 컴퍼넌트와 같습니다.

반환값:
컴퍼넌트

createHorizontalGlue

public static Component  createHorizontalGlue()
수평 방향의 접착제 컴퍼넌트를 작성합니다.

반환값:
컴퍼넌트

createVerticalGlue

public static Component  createVerticalGlue()
수직 방향의 접착제 컴퍼넌트를 작성합니다.

반환값:
컴퍼넌트

setLayout

public void setLayout(LayoutManager  l)
AWTError 를 throw 합니다. Box 는 BoxLayout 밖에 사용할 수 없습니다.

오버라이드(override):
클래스 Container 내의 setLayout
파라미터:
l - 사용하는 레이아웃 매니저
관련 항목:
Container.doLayout() , Container.getLayout()

paintComponent

protected void paintComponent(Graphics  g)
Box 를 그립니다. 이 Box 에 UI 가 있는 경우, 이 메소드는 상위 구현을 호출합니다. 이 Box 가 불투명한 경우,Graphics 는 백그라운드 칼라로 전부 칠해집니다.

오버라이드(override):
클래스 JComponent 내의 paintComponent
파라미터:
g - 페인트 되는 Graphics
예외:
NullPointerException - g 가 null 의 경우
도입된 버젼:
1.6
관련 항목:
JComponent.paint(java.awt.Graphics) , ComponentUI

getAccessibleContext

public AccessibleContext  getAccessibleContext()
이 박스에 관련한 AccessibleContext 를 돌려줍니다. 박스의 경우, AccessibleContext 는 AccessibleBox 의 형식을 취합니다. 필요에 따라서 신규의 AccessibleAWTBox 인스턴스가 생성됩니다.

정의:
인터페이스 Accessible 내의 getAccessibleContext
오버라이드(override):
클래스 JComponent 내의 getAccessibleContext
반환값:
이 Box 의 AccessibleContext 로서 기능하는 AccessibleBox

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 도 참조해 주세요.