1
2 JComboBox comboBoxRow= new JComboBox();
3
4 comboBoxRow.setRenderer(new ListCellRenderer() {
5 private ListCellRenderer renderer = comboBoxRow.getRenderer();
6 public Component getListCellRendererComponent(JList list,
7 Object value, int index, boolean isSelected, boolean cellHasFocus) {
8 Component component = renderer.getListCellRendererComponent(
9 list, value, index, isSelected, cellHasFocus);
10 if (component instanceof JLabel) {
11 JLabel label = (JLabel) component;
12 label.setToolTipText(label.getText());
13 }
14 return component;
15 }
16 });
眼镜蛇