Está aparecendo o seguinte erro ao compilar:
symbol : constructor JTable(java.util.ArrayList,java.lang.String[])
location: class javax.swing.JTable
JTable table = new JTable(dados, colunas);
Note: C:\Consulta.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
import java.awt.Dimension;
import java.sql.ResultSet;
import java.sql.PreparedStatement;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import javax.swing.JTable;
public class Consulta extends javax.swing.JFrame {
private Contatos_Conexao conexao = new Contatos_Conexao();
private String Sql;
PreparedStatement pstm;
ResultSet RS;
ArrayList dados = new ArrayList();
String[] colunas = new String[] { "Codigo", "Nome", "Telefone" };
public Consulta() {
initComponents();
}
private void jbt_ConsultarActionPerformed(java.awt.event.ActionEvent evt) {
try {
conexao.conecta_Contatos();
System.out.println("entrei");
Sql = "SELECT CODIGO, NOME, FIXO FROM TELEFONES ORDER BY NOME";
pstm = conexao.con.prepareStatement(Sql);
RS = pstm.executeQuery();
while (RS.next()) {
dados.add(new String[] {RS.getString("CODIGO"),RS.getString("NOME"), RS.getString("FIXO") });
}
} catch(Exception e){
JOptionPane.showMessageDialog(null, "Erro ao listar.", "Mensagens", JOptionPane.INFORMATION_MESSAGE);
System.out.println(e.getMessage());
}
fecha_Conexoes();
JTable table = new JTable(dados_Continentes, colunas_Continentes);
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
}
private void fecha_Conexoes() {
try {
RS.close();
pstm.close();
conexao.desconecta_Contatos();
} catch(Exception e){
JOptionPane.showMessageDialog(null, "Erro ao Fechar as conexões.", "Mensagens", JOptionPane.INFORMATION_MESSAGE);
System.out.println(e.getMessage());
}
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Consulta().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jbt_Consultar;
// End of variables declaration
}