下面列出了javax.swing.JTable#getDropLocation ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
Color fg = null;
Color bg = null;
JTable.DropLocation dropLocation = table.getDropLocation();
if (dropLocation != null
&& !dropLocation.isInsertRow()
&& !dropLocation.isInsertColumn()
&& dropLocation.getRow() == row
&& dropLocation.getColumn() == column) {
fg = DefaultLookup.getColor(this, ui, "Table.dropCellForeground");
bg = DefaultLookup.getColor(this, ui, "Table.dropCellBackground");
isSelected = true;
}
if (isSelected) {
setBackground(DefaultLookup.getColor(this, ui, "Table.dropCellBackground"));
} else {
setBackground( DefaultLookup.getColor(this, ui, "Table.alternateRowColor"));
}
MapRule rule=(MapRule)value;
update(rule,table,row);
return this;
}
public void updateComponentSelectedState(JComponent c, boolean isSelected, JTable table, int row, int column, boolean hasFocus) {
Color fg = null;
Color bg = null;
JTable.DropLocation dropLocation = table.getDropLocation();
if (dropLocation != null
&& !dropLocation.isInsertRow()
&& !dropLocation.isInsertColumn()
&& dropLocation.getRow() == row
&& dropLocation.getColumn() == column) {
isSelected = true;
}
if (isSelected) {
c.setForeground(fg == null ? table.getSelectionForeground() : fg);
c.setBackground(bg == null ? table.getSelectionBackground() : bg);
} else {
Color background = unselectedBackground != null
? unselectedBackground
: table.getBackground();
c.setForeground(unselectedForeground != null
? unselectedForeground
: table.getForeground());
c.setBackground(background);
}
c.setFont(table.getFont());
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
Color fg = null;
Color bg = null;
JTable.DropLocation dropLocation = table.getDropLocation();
if (dropLocation != null
&& !dropLocation.isInsertRow()
&& !dropLocation.isInsertColumn()
&& dropLocation.getRow() == row
&& dropLocation.getColumn() == column) {
fg = DefaultLookup.getColor(this, ui, "Table.dropCellForeground");
bg = DefaultLookup.getColor(this, ui, "Table.dropCellBackground");
isSelected = true;
}
if (isSelected) {
setBackground(DefaultLookup.getColor(this, ui, "Table.dropCellBackground"));
} else {
setBackground( DefaultLookup.getColor(this, ui, "Table.alternateRowColor"));
}
MapRule rule=(MapRule)value;
update(rule,table,row);
return this;
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
int row, int column) {
if (table == null) {
return this;
}
lbl.setFont(table.getFont().deriveFont(Font.BOLD));
Color fg = null;
Color bg = null;
JTable.DropLocation dropLocation = table.getDropLocation();
if (dropLocation != null && !dropLocation.isInsertRow() && !dropLocation.isInsertColumn()
&& dropLocation.getRow() == row && dropLocation.getColumn() == column) {
fg = UIManager.getColor("Table.dropCellForeground");
bg = UIManager.getColor("Table.dropCellBackground");
isSelected = true;
}
if (isSelected) {
super.setForeground(fg == null ? table.getSelectionForeground() : fg);
super.setBackground(bg == null ? table.getSelectionBackground() : bg);
} else {
Color background = unselectedBackground != null ? unselectedBackground : table.getBackground();
if (background == null || background instanceof javax.swing.plaf.UIResource) {
Color alternateColor = UIManager.getColor("Table.alternateRowColor");
if (alternateColor != null && row % 2 != 0) {
background = alternateColor;
}
}
super.setForeground(unselectedForeground != null ? unselectedForeground : table.getForeground());
super.setBackground(background);
}
setFont(table.getFont());
if (hasFocus) {
Border border = null;
if (isSelected) {
border = UIManager.getBorder("Table.focusSelectedCellHighlightBorder");
}
if (border == null) {
border = UIManager.getBorder("Table.focusCellHighlightBorder");
}
setBorder(border);
if (!isSelected && table.isCellEditable(row, column)) {
Color col;
col = UIManager.getColor("Table.focusCellForeground");
if (col != null) {
super.setForeground(col);
}
col = UIManager.getColor("Table.focusCellBackground");
if (col != null) {
super.setBackground(col);
}
}
} else {
setBorder(getNoFocusBorder());
}
return this;
}