import javax.swing.tree.*; import javax.swing.*; import java.awt.*; import java.util.*; class OntoTreeRendererComponent implements TreeCellRenderer{ JSlider slider=new JSlider(); //Dictionary dict=new Hashtable(); JLabel label=new JLabel("test"); JPanel p=new JPanel(new GridLayout(1, 2)); OntoApp oa; public OntoTreeRendererComponent(OntoApp uoa){ oa=uoa; p.add(label); p.add(slider); // dict.put(new Integer(1), label); //slider.setLabelTable(dict); p.setPreferredSize(new Dimension(100, 20)); // slider.addChangeListener(oa.otm); // label.addActionListener(oa.otm); label.addMouseListener(oa.otm); slider.addMouseListener(oa.otm); } public Component getTreeCellRendererComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row, boolean hasFocus){ OntoParam onp=(OntoParam)value; // oa.otm.editableop=onp; slider.setValue((int)(onp.coef*100)); label.setText(onp.name); label.setToolTipText(onp.name); slider.setToolTipText(onp.getActualCoef()+""); //System.out.println(isSelected+" "+hasFocus); if(isSelected){ label.setBackground(Color.blue); p.setBackground(Color.blue); slider.setBackground(Color.blue); } else { label.setBackground(Color.white); p.setBackground(Color.white); slider.setBackground(Color.white); } return p; } }