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 54 55 56 57
|
public class CheckListCellRenderer extends JPanel implements ListCellRenderer, ChangeListener
{
private Scenario sCorrespondant;
private ListCellRenderer delegate;
private ListSelectionModel selectionModel;
private JPanel jpNom,jpFrequence;
private jsFrequence jsfFrequence;
public CheckListCellRenderer(Scenario _s,ListCellRenderer renderer, ListSelectionModel selectionModel)
{
this.sCorrespondant=_s;
this.delegate = renderer;
this.selectionModel = selectionModel;
jsfFrequence=new jsFrequence(false);
jsfFrequence.addChangeListener(this);
jsfFrequence.setOpaque(false);
jpNom=new JPanel(new BorderLayout());
jpNom.setMinimumSize(new Dimension(160,45));
jpNom.setPreferredSize(new Dimension(160,45));
jpNom.setMaximumSize(new Dimension(160,45));
jpNom.setOpaque(false);
jpFrequence=new JPanel(new BorderLayout());
jpFrequence.setOpaque(false);
setLayout(new FlowLayout());
setOpaque(false);
}
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus){
Component renderer = delegate.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
removeAll();
if(!list.isSelectionEmpty())
{
StyleFrequence sfTmp=sCorrespondant.donnePlagesDefaut().donne1StyleFrequence(list.getSelectedValue().toString());
if(sfTmp!=null)
jsfFrequence.setValue(sfTmp.getIFrequence());
}
jpNom.add(renderer,BorderLayout.CENTER);
jpFrequence.add(jsfFrequence,BorderLayout.CENTER);
add(jpNom);
add(Box.createHorizontalStrut(1));
add(jpFrequence);
return this;
}
public void stateChanged(ChangeEvent arg0)
{
//jsfFrequence.repaint();
}
} |
Partager