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
|
public class MediaContactCellRenderer extends JPanel implements ListCellRenderer {
private static final String htmlText1 = "<html><table border=1 cellspacing=0 cellpadding=0 width =100%><tr><td rowspan=2>";
private static final String htmlText2 = "</td><td>";
private static final String htmlText3 = "</td><tr><td align='right'>";
private static final String htmlText4 = "</td></tr></table></html>";
private JLabel valueLabel = new JLabel();
private JLabel noteLabel = new JLabel();
protected static Border noFocusBorder;
public MediaContactCellRenderer(){
super();
setOpaque(true);
/**
ajouter les labels au panneau, je vous epargne les details
*/
}
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
//MediaContact est un simple javabean avec des getters et des setters
MediaContact mc = (MediaContact) value;
noteLabel.setText(mc.getNote());
valueLabel.setText(mc.getValue());
/**
traitement relatif à la gestion de selection et focus
*/
return this;
}
} |
Partager