1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 package com.buckosoft.fibs.BuckoFIBS.gui.inviterList;
50
51 import java.awt.Color;
52 import java.awt.Component;
53 import java.awt.Dimension;
54 import java.awt.Font;
55 import java.awt.GridBagConstraints;
56 import java.awt.GridBagLayout;
57 import java.awt.Insets;
58
59 import javax.swing.ImageIcon;
60 import javax.swing.JLabel;
61 import javax.swing.JPanel;
62 import javax.swing.JTable;
63 import javax.swing.table.TableCellRenderer;
64
65 import com.buckosoft.fibs.domain.Player;
66
67
68
69
70
71
72
73 public class InviterNameRenderer extends JPanel implements TableCellRenderer {
74 private static final long serialVersionUID = 1L;
75 private Color selectedBackgroundColor;
76 private JLabel jLabel = null;
77 private JLabel jLabelIcon = null;
78 private ImageIcon warningIcon = new ImageIcon(getClass().getResource("/g/caution.png"));
79
80
81
82
83
84 public InviterNameRenderer() {
85 super();
86 initialize();
87 }
88
89
90
91
92
93 private void initialize() {
94 GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
95 gridBagConstraints1.insets = new Insets(0, 0, 0, 0);
96 gridBagConstraints1.gridx = 1;
97 gridBagConstraints1.gridy = 0;
98 gridBagConstraints1.anchor = GridBagConstraints.EAST;
99 gridBagConstraints1.weightx = 0.2;
100 gridBagConstraints1.gridheight = 1;
101 GridBagConstraints gridBagConstraints = new GridBagConstraints();
102 gridBagConstraints.insets = new Insets(0, 0, 0, 0);
103 gridBagConstraints.gridx = 0;
104 gridBagConstraints.gridy = 0;
105 gridBagConstraints.anchor = GridBagConstraints.WEST;
106 gridBagConstraints.gridheight = 1;
107 jLabelIcon = new JLabel();
108 jLabel = new JLabel();
109 jLabel.setFont(new Font("Dialog", Font.PLAIN, 12));
110 jLabel.setText("JLabel");
111 this.setLayout(new GridBagLayout());
112 this.setSize(new Dimension(79, 22));
113 this.add(jLabel, gridBagConstraints);
114 this.add(jLabelIcon, gridBagConstraints1);
115 }
116
117 public void setSelectedBackground(Color color) {
118 selectedBackgroundColor = color;
119 }
120
121
122
123
124 @Override
125 public Component getTableCellRendererComponent(JTable table, Object value,
126 boolean isSelected, boolean hasFocus, int row, int column) {
127 Player p = (Player)value;
128 this.setOpaque(true);
129 this.jLabel.setOpaque(true);
130 if (isSelected) {
131 this.setBackground(selectedBackgroundColor);
132 this.jLabel.setBackground(selectedBackgroundColor);
133 } else {
134 this.setBackground(Color.white);
135 this.jLabel.setBackground(Color.white);
136 }
137 this.jLabel.setText(p.getName());
138 this.jLabel.setOpaque(true);
139 if (p.getBfStatus() != null && p.getBfStatus().length() > 0) {
140 this.jLabelIcon.setIcon(warningIcon);
141 this.setToolTipText(p.getBfStatus());
142 } else {
143 this.jLabelIcon.setIcon(null);
144 this.setToolTipText(null);
145
146 }
147 return this;
148 }
149
150 }