CompositeView

CompositeView (복합 뷰)

하나 이상의 자식 뷰를 관리하는 추상 View 구현입니다. 비교적 적은 수의 자식 뷰를 관리하도록 설계되었습니다.

출처: Java API Reference

본문

CompositeView는 BoxView처럼 자식 View를 포함할 View 구현의 출발점으로 쓰입니다. 자식 View 모음을 관리하려는 하위 클래스는 replace(int, int, javax.swing.text.View[]) 메서드를 사용해야 합니다. View가 DocumentListener 알림 중에 replace를 호출하므로 보통 직접 replace를 호출할 필요는 없습니다.

CompositeView는 자식 View에 레이아웃 정책을 강요하지 않지만, 포함할 자식 View에 여백(insets)을 넣을 수 있습니다. 여백은 setInsets(short, short, short, short) 또는 setParagraphInsets(AttributeSet)으로 설정할 수 있습니다.

하위 클래스는 isBefore, isAfter, getViewAtPoint, childAllocation을 오버라이드해야 합니다.

주요 메서드·상세 (Methods & details)

주요 메서드로는 자식 뷰를 교체하는 replace(int, int, View[]), 여백을 설정하는 setInsets(short, short, short, short)/setParagraphInsets(AttributeSet), 자식 배치를 얻는 getChildAllocation(int, Shape), 특정 위치의 뷰를 찾는 getViewAtPoint(int, int, Rectangle) 등이 있습니다. 이들은 하위 클래스에서 오버라이드되어 레이아웃 정책을 구현합니다.

더 알아보기 (Learn more)

Java 공식 API