?? dtableui.java
字號:
package table;
import javax.swing.table.*;
import javax.swing.plaf.basic.*;
import java.awt.*;
import javax.swing.*;
class DTableUI extends BasicTableUI {
public void paint(Graphics g, JComponent c) {
// Rectangle r = g.getClipBounds();
// int firstRow = table.rowAtPoint(new Point(0, r.y));
// int lastRow = table.rowAtPoint(new Point(0, r.y + r.height));
// if (lastRow < 0)
// lastRow = table.getRowCount() - 1;
// for (int i = firstRow; i <= lastRow; i++)
// paintRow(i, g);
for(int i=0;i< table.getRowCount();i++){
paintRow(i, g);
}
}
private void paintRow(int row, Graphics g) {
Rectangle clipBounds = g.getClipBounds();
GridSplit gridSplit = ((DTable) table).getGridSplit();
for (int i = 0; i < table.getColumnCount(); i++) {
if (gridSplit.isVisible(row, i)) {
Rectangle rec = table.getCellRect(row, i, true);
if (rec.intersects(clipBounds)) {
paintCell(row, i, g, rec);
}
}
}
}
private void paintCell(int row, int column, Graphics g, Rectangle area) {
int verticalMargin = table.getRowMargin();
int horizontalMargin = table.getColumnModel().getColumnMargin();
Color c = g.getColor();
g.setColor(table.getGridColor());
g.drawRect(area.x, area.y, area.width - 1, area.height - 1);
g.setColor(c);
area.setBounds(area.x + horizontalMargin / 2, area.y + verticalMargin
/ 2, area.width - horizontalMargin, area.height
- verticalMargin);
if (table.isEditing() && table.getEditingRow() == row
&& table.getEditingColumn() == column) {
Component component = table.getEditorComponent();
component.setBounds(area);
component.validate();
} else {
TableCellRenderer renderer = table.getCellRenderer(row, column);
Component component = table.prepareRenderer(renderer, row, column);
if (component.getParent() == null)
rendererPane.add(component);
rendererPane.paintComponent(g, component, table, area.x, area.y,area.width, area.height, true);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -