Vous devez être membre et vous identifier pour publier un article.
Les visiteurs peuvent toutefois commenter chaque article par une réponse.
Article publié le Lundi 21 Janvier 2008, 14:54
package be.mil.cccis.atdl3.util.renderer; import java.awt.Component; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.ListCellRenderer; import javax.swing.ToolTipManager; import be.mil.cccis.atdl3.domain.generic.Catalog; /** * Provides custom display for <code>be.mil.cccis.atdl3.domain.generic.Catalog</code>. * Paints it contents in two columns CODE and DESCRIPTION. * @author gaudry.s * */ /** * */ private static final long serialVersionUID = 162343178097966067L; /** * Creates a new renderer */ public CatalogComboBoxRenderer() { setOpaque(true); setHorizontalAlignment(LEFT); setVerticalAlignment(CENTER); } /* (non-Javadoc) * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean) */ int index, boolean isSelected, boolean cellHasFocus) { if(value==null){ setText(""); } else{ if(value instanceof Catalog){ Catalog item = (Catalog)value; setText( "<html><body>"+item.getCode()+"</body></html>" ); setToolTipText( "<html><body> <b>"+item.getCode() + "</b> <i>" + description+"</i> </body></html>"); } else setText("<html><body>"+value.toString()+"</body></html>"); } setBackground(isSelected ? list.getSelectionBackground() : list.getBackground()); setForeground(isSelected ? list.getSelectionForeground() : list.getForeground()); return this; } }
Et là je ne suis pas d'accord du tout de laisser au modèle la responsabilité d'une certaine logique de présentation, mais c'est ce qui arrive quand on travaille à plusieurs en projet), le Renderer enrobe le texte aussi par des balises HTML.
Un article de Steph, lu 609 fois.Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.
132 mots clés dont 1 définis manuellement (plus d'information...).
Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.
Recherche (afficher)
Utilisateur (masquer)
Navigation (masquer)
Apparence (afficher)
Stats (afficher)
Citation (masquer)