Pessoal deem uma olhada aí nesse codigo e me digam, por favor, onde esta o erro:
Essa classe me retorna uma tabela preenchida com dados q vem de um banco:
public class Tela extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
private static Vector linhas;
private JTable jTable = null;
@SuppressWarnings( { "static-access", "deprecation" })
public Tela(Vector linhas) throws HeadlessException {
// TODO Auto-generated constructor stub
super();
this.linhas = linhas;
initialize();
show();
}
public Tela(GraphicsConfiguration arg0) {
super(arg0);
// TODO Auto-generated constructor stub
initialize();
}
public Tela(String arg0) throws HeadlessException {
super(arg0);
// TODO Auto-generated constructor stub
initialize();
}
public Tela(String arg0, GraphicsConfiguration arg1) {
super(arg0, arg1);
// TODO Auto-generated constructor stub
initialize();
}
/**
* @param linhas
* @throws SQLException
*/
private void mostrarResultados(Vector linhas) throws SQLException {
Vector<String> colunas = new Vector<String>();
colunas.add("ID");
colunas.add("NOME");
colunas.add("NASCIMENTO");
[b]jTable = new JTable(linhas, colunas);[/b]
JScrollPane jScrollPane = new JScrollPane(jTable);
getContentPane().add(jScrollPane, java.awt.BorderLayout.CENTER);
validate();
}
private void getTable() {
try {
mostrarResultados(linhas);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* This method initializes jScrollPane
*
* @return javax.swing.JScrollPane
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Tela thisClass = new Tela(linhas);
thisClass.setVisible(true);
}
});
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
getTable();
this.setSize(350, 230);
this.setTitle("Resultado");
}
}
No programa principal eu tenho :
private static Vector transformaEmVector(ContatoTO contato) {
// TODO Auto-generated method stub
Vector linha = new Vector();
linha.add(contato.getId());
linha.add(contato.getNome());
linha.add(contato.getNascimento());
return linha;
}
for (ContatoTO contatoTO : objetos) {
Vector linha= transformaEmVector(contato);
new Tela(linha);
}
Ta dando o seguinte erro:
Exception in thread “main” java.lang.ClassCastException: java.lang.Integer
at javax.swing.table.DefaultTableModel.justifyRows(Unknown Source)
at javax.swing.table.DefaultTableModel.setDataVector(Unknown Source)
at javax.swing.table.DefaultTableModel.(Unknown Source)
at javax.swing.JTable.(Unknown Source)
at com.googlepages.tacianosilva.agenda.Tela.mostrarResultados(Tela.java:69)
at com.googlepages.tacianosilva.agenda.Tela.getTable(Tela.java:78)
at com.googlepages.tacianosilva.agenda.Tela.initialize(Tela.java:108)
at com.googlepages.tacianosilva.agenda.Tela.(Tela.java:31)
at com.googlepages.tacianosilva.agenda.MainTeste.main(MainTeste.java:42)
Quais as possiveis causar pra isso?