第一篇文章,如果我犯了错误,请原谅我!
在我的jTable" ID","名称"来自数据库的值显示但是"余额"没有按'吨!
原因是什么?
这是源代码:
private void formWindowOpened(java.awt.event.WindowEvent evt) {
// TODO add your handling code here:
Tools.setCenter(this);
DAL d = new DAL();
Object[][] Customer = d.select("select * from customer");
String[] column = {"ID", "Name", "Balance"};
jTable1 = new javax.swing.JTable(Customer, column);
jScrollPane1.setViewportView(jTable1);
}
private void jTextField1KeyPressed(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
if (evt.getKeyCode() == 27) {
this.setVisible(false);
}
}
答案 0 :(得分:0)
您没有提到所需的确切代码! 希望你创建了3列的表.. 试试这段代码
ps=con.prepareStatement("select * from customer");
rs=ps.exectuteQuery();
while(rs.next())
{
int row=0;
for(int i=1,i<=rsmd.getColumnCount();i++)
{
jTable1.setValueAt(rs.getString(i),row,i-1);
}
row=row+1;
}