Ver Mensaje Individual
  #20 (permalink)  
Antiguo 11/10/2011, 06:34
jdmc
 
Fecha de Ingreso: diciembre-2010
Mensajes: 6
Antigüedad: 13 años, 5 meses
Puntos: 0
Respuesta: Agregar JButton a JTable

Hola! Aquí está el código que copie, y en el actionPerformed se encuentran las nuevas líneas que llaman al proceso que necesito que se ejcute.

Cita:
public class myeditor extends AbstractCellEditor implements TableCellEditor, ActionListener{

private static final long serialVersionUID = 1L;
Boolean currentValue;
JButton avisos;
protected static final String EDIT = "edit";
private JTable jTable1;

public myeditor(JTable jTable1) {
avisos = new JButton();
avisos.setActionCommand(EDIT);
avisos.addActionListener((ActionListener) this);
avisos.setBorderPainted(false);
avisos.setSize(10, 10);
this.jTable1 = jTable1;
}

public void actionPerformed(ActionEvent e) {
XX_PlanWeekPayForm f = new XX_PlanWeekPayForm();
f.cmdAvisos();

fireEditingStopped();
}

/**
* Implement the one CellEditor method that AbstractCellEditor doesn't.
*/
public Object getCellEditorValue() {
return currentValue;
}

/**
* Implement the one method defined by TableCellEditor.
*/
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
//Va a mostrar el botón solo en la última fila de otra forma muestra un espacio en blanco.
// if (row == table.getModel().getRowCount() - 1) {
currentValue = (Boolean) value;
return avisos;
// }
return new JLabel();
}
Gracias

Saludos