protected void paintCell(Graphics g,int row,Rectangle rowBounds,ListCellRenderer cellRenderer,ListModel dataModel,ListSelectionModel selModel,int leadIndex){
  Object value=dataModel.getElementAt(row);
  boolean cellHasFocus=list.hasFocus() && (row == leadIndex);
  boolean isSelected=selModel.isSelectedIndex(row);
  Component rendererComponent=cellRenderer.getListCellRendererComponent(list,value,row,isSelected,cellHasFocus);
  int cx=rowBounds.x;
  int cy=rowBounds.y;
  int cw=rowBounds.width;
  int ch=rowBounds.height;
  if (isFileList) {
    int w=Math.min(cw,rendererComponent.getPreferredSize().width + 4);
    if (!isLeftToRight) {
      cx+=(cw - w);
    }
    cw=w;
  }
  rendererPane.paintComponent(g,rendererComponent,list,cx,cy,cw,ch,true);
}

protected void paintCell ( Graphics g , int row , Rectangle rowBounds , ListCellRenderer cellRenderer , ListModel dataModel , ListSelectionModel selModel , int leadIndex ) { Object value = dataModel . getElementAt ( row ) ; boolean cellHasFocus = list . hasFocus ( ) && ( row == leadIndex ) ; boolean isSelected = selModel . isSelectedIndex ( row ) ; Component rendererComponent = cellRenderer . getListCellRendererComponent ( list , value , row , isSelected , cellHasFocus ) ; int cx = rowBounds . x ; int cy = rowBounds . y ; int cw = rowBounds . width ; int ch = rowBounds . height ; if ( isFileList ) { int w = Math . min ( cw , rendererComponent . getPreferredSize ( ) . width + 4 ) ; if ( ! isLeftToRight ) { cx += ( cw - w ) ; } cw = w ; } rendererPane . paintComponent ( g , rendererComponent , list , cx , cy , cw , ch , true ) ; }
paint one list cell : compute the relevant state , get the " rubber stamp " cell renderer component , and then use the cellrendererpane to paint it . subclasses may want to override this method rather than paint ( ) .
