kadreg profil: Utilisateur | Code :
- class CheckRenderer extends JPanel implements TreeCellRenderer {
- protected JCheckBox check;
- protected TreeLabel label;
- public CheckRenderer() {
- setLayout(null);
- add(check = new JCheckBox());
- add(label = new TreeLabel());
- check.setBackground(UIManager.getColor("Tree.textBackground" ));
- label.setForeground(UIManager.getColor("Tree.textForeground" ));
- }
- public Component getTreeCellRendererComponent(JTree tree, Object value,
- boolean isSelected, boolean expanded, boolean leaf, int row,
- boolean hasFocus) {
- String stringValue = tree.convertValueToText(value, isSelected,
- expanded, leaf, row, hasFocus);
- setEnabled(tree.isEnabled());
- check.setSelected(((CheckNode) value).isSelected());
- label.setFont(tree.getFont());
- label.setText(stringValue);
- label.setSelected(isSelected);
- label.setFocus(hasFocus);
- if (leaf) {
- label.setIcon(UIManager.getIcon("Tree.leafIcon" ));
- } else if (expanded) {
- label.setIcon(UIManager.getIcon("Tree.openIcon" ));
- } else {
- label.setIcon(UIManager.getIcon("Tree.closedIcon" ));
- }
- return this;
- }
|
---------------
brisez les rêves des gens, il en restera toujours quelque chose... -- laissez moi troller sur discu !
|