Jtable CellRender e selecionar linhas :)

0 respostas
D

Pessoal depois que eu implementei este código em meu sistema quando eu seleciono uma linha da Jtable, as celulas que são redenrizadas por esta classe não podem mais ser selecionadas, mas eu preciso que elas sejam selecionadas o que fazer?

Segue o codigo:

package gui;

import java.awt.Component;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.TableCellRenderer;

/**
 *
 * @author kenedy
 */
public class QuantidadeCellRender extends JLabel implements TableCellRenderer {
  
     private static final long serialVersionUID = 1L;  
     private JLabel cell = null;  
     DecimalFormat nf = new DecimalFormat("#,##0.00");
            
     private JLabel getCell() {  
         if (cell == null)  
             cell = new JLabel();  
         return cell;  
     }                  
     public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {  
         if (value != null) {  
             BigDecimal teste = new BigDecimal(value.toString());
             nf.setParseBigDecimal(true);
             getCell().setText(nf.format(teste.doubleValue()));  
             getCell().setHorizontalAlignment(SwingConstants.RIGHT);
         } else getCell().setText("");  
         return getCell();  
     }

}

E aki o trecho em que eu o coloco em uso na jtable

jTable16.getColumnModel().getColumn(1).setCellRenderer(new QuantidadeCellRender());

Criado 17 de julho de 2008
Respostas 0
Participantes 1