|
|
|
@ -48,9 +48,17 @@ public class CopyableJTable extends SortableJTable {
|
|
|
|
|
boolean mouseDrag = false; |
|
|
|
|
boolean headerSelect = false; |
|
|
|
|
|
|
|
|
|
DefaultTableCellRenderer tableHeaderCellRenderer = new DefaultTableCellRenderer() { |
|
|
|
|
|
|
|
|
|
class CopyableTableHeaderCellRenderer implements TableCellRenderer { |
|
|
|
|
TableCellRenderer tableCellRenderer; |
|
|
|
|
|
|
|
|
|
CopyableTableHeaderCellRenderer(TableCellRenderer tableCellRenderer) { |
|
|
|
|
this.tableCellRenderer = tableCellRenderer; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { |
|
|
|
|
JComponent comp = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); |
|
|
|
|
JComponent comp = (JComponent) this.tableCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); |
|
|
|
|
if (isChoose(row, column)) { |
|
|
|
|
comp.setBackground(selectBackGround); |
|
|
|
|
} else { |
|
|
|
@ -58,13 +66,13 @@ public class CopyableJTable extends SortableJTable {
|
|
|
|
|
} |
|
|
|
|
return comp; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public CopyableJTable(TableSorter tableModel) { |
|
|
|
|
super(tableModel); |
|
|
|
|
initListener(); |
|
|
|
|
this.getTableHeader().setDefaultRenderer(tableHeaderCellRenderer); |
|
|
|
|
this.getTableHeader().setDefaultRenderer(new CopyableTableHeaderCellRenderer(this.getTableHeader().getDefaultRenderer())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initListener() { |
|
|
|
|