01: package org.swingml.tablebrowser.ext;
02:
03: import java.awt.Component;
04:
05: import javax.swing.ImageIcon;
06: import javax.swing.JButton;
07: import javax.swing.JTable;
08: import javax.swing.SwingConstants;
09: import javax.swing.table.TableCellRenderer;
10:
11: public class JComponentCellRenderer extends JButton implements
12: TableCellRenderer {
13: int sortOrderNumber;
14: String sortOrder;
15:
16: public JComponentCellRenderer(String order, int i) {
17: super ("");
18: sortOrderNumber = i;
19: sortOrder = order;
20: }
21:
22: public JComponentCellRenderer(ImageIcon icon, int i) {
23: super ("", icon);
24: sortOrderNumber = i;
25: }
26:
27: public Component getTableCellRendererComponent(JTable table,
28: Object value, boolean isSelected, boolean hasFocus,
29: int row, int column) {
30: setText(value.toString() + " " + sortOrderNumber
31: + (sortOrder != null ? " " + sortOrder : ""));
32: this.setVerticalTextPosition(SwingConstants.CENTER);
33: this.setHorizontalTextPosition(SwingConstants.RIGHT);
34: return this;
35: }
36:
37: }
|