JavaTM Platform
Standard Ed. 6

javax.swing.table
인터페이스 TableCellRenderer

기존의 구현 클래스의 일람:
DefaultTableCellRenderer , DefaultTableCellRenderer.UIResource


public interface TableCellRenderer

이 인터페이스는,JTable 의 셀의 렌더링이 될 가능성이 있는 객체가 요구하는 메소드를 정의합니다.


메소드의 개요
 Component getTableCellRendererComponent (JTable  table, Object  value, boolean isSelected, boolean hasFocus, int row, int column)
          셀을 draw 하는데 사용되는 컴퍼넌트를 돌려줍니다.
 

메소드의 상세

getTableCellRendererComponent

Component  getTableCellRendererComponent(JTable  table,
                                        Object  value,
                                        boolean isSelected,
                                        boolean hasFocus,
                                        int row,
                                        int column)
셀을 draw 하는데 사용되는 컴퍼넌트를 돌려줍니다. draw 하기 전에, 이 메소드를 사용해 렌더링을 적절히 설정합니다.

테이블의 현재의 드래그 & 드롭 위치를 나타내는 셀이 있으면,TableCellRenderer 도 이 셀을 draw 하기 위해서 사용됩니다. 이 렌더링이 드래그 & 드롭 위치의 draw를 고려하는 경우, 테이블을 직접 조회해, 지정의 행 및 열이 드롭 위치를 나타내고 있는지 어떤지를 확인하게 되어 있습니다.

     JTable.DropLocation dropLocation = table.getDropLocation();
     if (dropLocation ! = null
             && ! dropLocation.isInsertRow()
             && ! dropLocation.isInsertColumn()
             && dropLocation.getRow() == row
             && dropLocation.getColumn() == column) {

         // this cell represents the current drop location
         // so render it specially, perhaps with a different color
     }
 

인쇄 조작중은, 인쇄 결과에 선택 범위나 포커스가 표시되는 것을 막기 위해,isSelectedhasFocus 의 값을 false 로 해 이 메소드를 호출합니다. 테이블을 인쇄할지 어떨지에 근거해 그 외의 커스터마이즈를 실시하려면 ,JComponent.isPaintingForPrint() 의 반환값을 확인합니다.

파라미터:
table - draw 하는 렌더링을 조회하는 JTable. null 도 가능
value - 렌더링 되는 셀의 값. 값을 해석 및 draw 하는 방법은 렌더링에 따라서 다르다. 예를 들어, value 캐릭터 라인 "true" 인 경우는 캐릭터 라인으로서 draw 되는지, 체크된 체크 박스로서 draw 된다. null 도 유효한 값
isSelected - 셀이 하이라이트로 draw 되고 있는 경우는 true, 그렇지 않은 경우는 false
hasFocus - true 의 경우, 셀을 적절히 draw 한다. 예를 들어 셀이 편집 가능한 경우는, 셀에 특별한 경계를 붙여 편집을 나타내는 색으로 draw 하는
row - draw 되는 셀의 행 인덱스. 헤더를 draw 하는 경우, row 의 값은 -1
column - draw 되는 셀의 열인덱스
관련 항목:
JComponent.isPaintingForPrint()

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