bom dia pessoa estou querendo alimenta um tabela com os dado se um arraylist mais não estou conseguindo, vou postar meu codgo para vcs dar uma olhada.
import java.awt.BorderLayout;
import java.util.logging.Level;
import java.util.logging.Logger;
import trans.Conexao;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* tela.java
*
* Created on 16/03/2012, 08:58:17
*/
/**
*
* @author Amaro
*/
public class tela extends javax.swing.JFrame {
private ArrayList<String> CLI_ID = new ArrayList<String>();
private ArrayList<String> VEI_PLACA = new ArrayList<String>();
/** Creates new form tela */
public tela() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton1.setText("jButton1");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(129, 129, 129)
.add(jButton1)
.addContainerGap(174, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(99, 99, 99)
.add(jButton1)
.addContainerGap(172, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Statement stmt = Conexao.get();
String sql = "SELECT udl.VEI_ID, udl.UDL_DH, v.CLI_ID, v.VEI_COD, v.VEI_PLC FROM arenateste.ult_dado_lido AS udl INNER JOIN veiculo AS v ON v.VEI_ID = udl.VEI_ID AND udl.UDL_DH < (NOW()- INTERVAL 5 DAY) ORDER BY udl.UDL_DH";
try {
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
this.VEI_PLACA.add(rs.getString("VEI_PLC"));
this.CLI_ID.add(rs.getString("CLI_ID"));
//System.out.println(VEI_ID);
}
for (int index = 0; index < VEI_PLACA.size(); index ++) {
System.out.println(VEI_PLACA.get(index)+"\t"+CLI_ID.get(index));
//System.out.println(CLI_ID.get(index));
}
} catch (SQLException ex) {
Logger.getLogger(tela.class.getName()).log(Level.SEVERE, null, ex);
}
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
int qtd = VEI_PLACA.size();
Object rowData[][] = new Object[qtd][3];
Object columnNames[] = { "Campo 01", "Campo 02", "campo 03" };
JTable table = new JTable(rowData, columnNames);
JScrollPane scrollPane = new JScrollPane(table);
frame.add(scrollPane, BorderLayout.CENTER);
frame.setSize(600, 300);
frame.setVisible(true);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new tela().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
// End of variables declaration
}
como vcs poder ver eu ja estou montando a tabela so não estou conseguindo alimenta ela