|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JLabel
javax.swing.table.DefaultTableCellRenderer
public class DefaultTableCellRenderer
呈現(顯示) JTable 中每個單元格的標準類別。
實作注意事項:此類別繼承自一個標準的元件類別 JLabel。但是 JTable 為其單元格的呈現使用了特殊的機制,因此要求稍微對其單元格渲染器的行為進行修改。該 table 類別定義一個單元格渲染器,並將其用作呈現表中所有單元格的橡皮圖章;它呈現第一個單元格、更改該單元格渲染器的內容、將原點移到新的位置、重新進行繪製,等等。標準的 JLabel 元件不是通過此方式使用的,每次繪製單元格時,我們都希望避免觸發 revalidate 事件。這會大大降低程序的性能,因為 revalidate 訊息會沿容器的層次結構向上傳遞,以確定任意其他元件是否將受到影響。由於該渲染器是繪製操作生命週期中唯一的父類別,類似地,我們也希望避免與為進行繪製操作而遍歷容器層次結構相關聯的開銷。所以此類別將 validate、invalidate、revalidate、repaint 和 firePropertyChange 方法覆寫為無操作,並單獨覆寫 isOpaque 方法以提高性能。如果您編寫自己的渲染器,請記住此性能方面的考慮。
警告:此類別的已序列化物件與以後的 Swing 版本不相容。當前的序列化支持適用於短期存儲或運行相同 Swing 版本的應用程序之間的 RMI。從 1.4 版本開始,已在 java.beans 套件中添加了支持所有 JavaBeansTM 長期存儲的功能。請參見 XMLEncoder。
JTable| 巢狀類別摘要 | |
|---|---|
static class |
DefaultTableCellRenderer.UIResource
DefaultTableCellRenderer 的一個子類別,它實作 UIResource。 |
| 從類別 javax.swing.JLabel 繼承的巢狀類別/介面 |
|---|
JLabel.AccessibleJLabel |
| 從類別 javax.swing.JComponent 繼承的巢狀類別/介面 |
|---|
JComponent.AccessibleJComponent |
| 從類別 java.awt.Container 繼承的巢狀類別/介面 |
|---|
Container.AccessibleAWTContainer |
| 從類別 java.awt.Component 繼承的巢狀類別/介面 |
|---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| 欄位摘要 | |
|---|---|
protected static Border |
noFocusBorder
一個空 Border。 |
| 從類別 javax.swing.JLabel 繼承的欄位 |
|---|
labelFor |
| 從類別 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 |
| 從介面 javax.swing.SwingConstants 繼承的欄位 |
|---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
| 從介面 java.awt.image.ImageObserver 繼承的欄位 |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| 建構子摘要 | |
|---|---|
DefaultTableCellRenderer()
創建一個預設的表單元格渲染器。 |
|
| 方法摘要 | |
|---|---|
void |
firePropertyChange(String propertyName,
boolean oldValue,
boolean newValue)
因為性能原因而被覆寫。 |
protected void |
firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
因為性能原因而被覆寫。 |
Component |
getTableCellRendererComponent(JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column)
返回預設的表單元格渲染器。 |
void |
invalidate()
因為性能原因而被覆寫。 |
boolean |
isOpaque()
因為性能原因而被覆寫。 |
void |
repaint()
因為性能原因而被覆寫。 |
void |
repaint(long tm,
int x,
int y,
int width,
int height)
因為性能原因而被覆寫。 |
void |
repaint(Rectangle r)
因為性能原因而被覆寫。 |
void |
revalidate()
因為性能原因而被覆寫。 |
void |
setBackground(Color c)
覆寫 JComponent.setBackground 將未選定單元格的背景色分派為指定顏色。 |
void |
setForeground(Color c)
覆寫 JComponent.setForeground 將未選定單元格的前景色分派為指定顏色。 |
protected void |
setValue(Object value)
將要呈現的單元格的 String 物件設置為 value。 |
void |
updateUI()
取自 UIManager 的關於外觀 [L&F] 已更改的通知。 |
void |
validate()
因為性能原因而被覆寫。 |
| 從類別 java.lang.Object 繼承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| 欄位詳細資訊 |
|---|
protected static Border noFocusBorder
Border。可以不使用此欄位。要更改此渲染器所使用的 Border,請覆寫 getTableCellRendererComponent 方法並直接設置所返回元件的邊界。
| 建構子詳細資訊 |
|---|
public DefaultTableCellRenderer()
| 方法詳細資訊 |
|---|
public void setForeground(Color c)
JComponent.setForeground 將未選定單元格的前景色分派為指定顏色。
JComponent 中的 setForegroundc - 將前景色設置為此值Component.getForeground()public void setBackground(Color c)
JComponent.setBackground 將未選定單元格的背景色分派為指定顏色。
JComponent 中的 setBackgroundc - 將背景色設置為此值Component.getBackground(),
JComponent.setOpaque(boolean)public void updateUI()
UIManager 的關於外觀 [L&F] 已更改的通知。用取自 UIManager 的最新版本 UI 物件替換當前的 UI 物件。
JLabel 中的 updateUIJComponent.updateUI()
public Component getTableCellRendererComponent(JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column)
在列印操作期間,將調用此方法(isSelected 和 hasFocus 為 false)阻止選擇和焦點在列印輸出中出現。要根據是否列印表進行其他定制,檢查 JComponent.isPaintingForPrint() 的返回值。
TableCellRenderer 中的 getTableCellRendererComponenttable - JTablevalue - 分派給 [row, column] 處單元格的值isSelected - 如果已選定單元格,則為 truehasFocus - 如果單元格具有焦點,則為 truerow - 要呈現的單元格所在行column - 要呈現的單元格所在列
JComponent.isPaintingForPrint()public boolean isOpaque()
JComponent 中的 isOpaqueJComponent.setOpaque(boolean)public void invalidate()
Container 中的 invalidateContainer.validate(),
Container.layout(),
LayoutManager,
LayoutManager2.invalidateLayout(Container)public void validate()
Container 中的 validateContainer.add(java.awt.Component),
Component.invalidate(),
JComponent.revalidate(),
Container.validateTree()public void revalidate()
JComponent 中的 revalidateComponent.invalidate(),
Container.validate(),
JComponent.isValidateRoot(),
RepaintManager.addInvalidComponent(javax.swing.JComponent)
public void repaint(long tm,
int x,
int y,
int width,
int height)
JComponent 中的 repainttm - 不使用此參數x - 髒區的 x 值y - 髒區的 y 值width - 髒區的寬度height - 髒區的高度Component.isShowing(),
RepaintManager.addDirtyRegion(javax.swing.JComponent, int, int, int, int)public void repaint(Rectangle r)
JComponent 中的 repaintr - 套件含髒區的 RectangleComponent.isShowing(),
RepaintManager.addDirtyRegion(javax.swing.JComponent, int, int, int, int)public void repaint()
Component 中的 repaintComponent.update(Graphics)
protected void firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
Component 中的 firePropertyChangepropertyName - 其值已改變的屬性oldValue - 該屬性以前的值newValue - 該屬性的新值
public void firePropertyChange(String propertyName,
boolean oldValue,
boolean newValue)
JComponent 中的 firePropertyChangepropertyName - 其值已更改的屬性oldValue - 該屬性以前的值newValue - 該屬性的新值protected void setValue(Object value)
String 物件設置為 value。
value - 此單元格的字元串值;如果 value 為 null,則將文本值設置為空字元串JLabel.setText(java.lang.String)
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 巢狀 | 欄位 | 建構子 | 方法 | 詳細資訊: 欄位 | 建構子 | 方法 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。