ciao a tutti ho una JList listaDate che mi visualizza un elenco di date.
questo il codice:

codice:
JList listaDate=listaDate=new JList(date);
class MyCellRenderer extends JLabel implements ListCellRenderer {
		     

		     public Component getListCellRendererComponent(
		       JList list,              // the list
		       Object value,            // value to display
		       int index,               // cell index
		       boolean isSelected,      // is the cell selected
		       boolean cellHasFocus)    // does the cell have focus
		     {
		         String s = value.toString();
		         System.out.println(getHorizontalTextPosition());
		         setText(s);

		         setHorizontalTextPosition(4);
		         if (index%2==0) {		                 
		        	 setBackground(new Color(220,220,255));
		        	 
		         } else {
		             setBackground(Color.white);
		         }
		         if(isSelected){
		        	 setBackground(new Color(255,255,102));
		         }
		         setEnabled(list.isEnabled());
		        
		         setFont(list.getFont());
		         setOpaque(true);//senza nn vedo lo sfondo colorato
		         return this;
		     }
		 }

		listaDate.setCellRenderer(new MyCellRenderer());
Il mio problema è che vorrei che le stringhe di testo(ovvero le date) non siano allineate a sinistra rispetto alla JList ma al centro..ho provato ad usare setAlignment,setHorizontalTextPosition e setHorizontalAlignment ma niente, continua a metterle sulla destra..come devo fare?