Bonjour,
j'aimerai régler un problème d'affichage sous windows et linux :
je travail sur un composant amélioré de JXTreeTable.
le probleme sous linux :
comme on le voit sur l'image il y a les petits tirets qui representent l'arborescence entre les noeuds, sous linux ils ne sont pas visibles. comment les afficher?
le probleme sous windows :
quand on regarde la colonne des checkbox on constate que le fond ne suit pas le highlight (une ligne sur deux grise). Cela marche parfaitement sous linux.
Comment recuperer la couleur du highlight sur cette ligne?
le Renderer associé :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
50
51
52
53 public class JXMapContextTableNodeRenderer implements TableCellRenderer{ private static final Border noFocusBorder = new EmptyBorder(1, 1, 1, 1); /** Creates a new instance of ASMutableCellRenderer */ public JXMapContextTableNodeRenderer() { super(); } public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JPanel comp = new JPanel(new GridLayout(1,1)); Object o = table.getValueAt(row,column); comp.setOpaque(true); if (isSelected) { comp.setForeground(table.getSelectionForeground()); comp.setBackground(table.getSelectionBackground()); } else { comp.setForeground(table.getForeground()); comp.setBackground(table.getBackground()); } if(o instanceof Boolean){ JCheckBox c = new JCheckBox(); c.setHorizontalAlignment(JLabel.CENTER); c.setBorderPainted(true); if (isSelected) { c.setForeground(table.getSelectionForeground()); c.setBackground(table.getSelectionBackground()); } else { c.setForeground(table.getForeground()); c.setBackground(table.getBackground()); } c.setSelected((value != null && ((Boolean)value).booleanValue())); if (hasFocus) { c.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder")); } else { c.setBorder(noFocusBorder); } comp.add(c); } return comp ; } }
Partager