Here I have a table template with 4 columns and several filled lines that I get in the database. I would like to create an Action button that copies columns 2 and 3 at once to the clipboard, so you can paste, for example, into an Excel or other places. It's possible?
Follow the Jtable template I'm using.
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;
public class MinhaTabelaEditavel extends AbstractTableModel {
private ArrayList linhas = null;
private String[] colunas = null;
public MinhaTabelaEditavel (ArrayList lin, String[] col){
setLinhas(lin);
setColunas(col);
}
public ArrayList getLinhas() {
return linhas;
}
public void setLinhas(ArrayList dados) {
this.linhas = dados;
}
public String[] getColunas() {
return colunas;
}
public void setColunas(String[] nome) {
this.colunas = nome;
}
public int getColumnCount(){
return colunas.length;
}
public int getRowCount (){
return linhas.size();
}
public String getColumnName (int numCol){
return colunas[numCol];
}
public Object getValueAt (int numLin, int numCol){
Object[] linha = (Object[])getLinhas().get(numLin);
return linha[numCol];
}
@Override
public boolean isCellEditable(int row, int column) {
return true;
}