我从JTable返回错误,插入2D矢量和String []作为标题...
try
{
refreshVector();
}
catch (Exception j)
{
throw j;
}
String[] headers = {"ID","Brand", "Item", "Details", "Qty", "Code", "re-order"};
JTable tbl_display = new JTable(data, headers);
JScrollPane scrollpane = new JScrollPane(tbl_display);
scrollpane.setBounds(120,120,600,300);
refreshVector方法包含...
public void refreshVector() throws Exception
{
dbconnect conn = new dbconnect();
try
{
conn.connect();
}
catch (Exception p)
{
throw p;
}
rs = conn.getData();
while(rs.next())
{
Vector<Object> vec = new Vector<Object>();
vec.add(rs.getString("ID_product"));
vec.add(rs.getString("brand"));
vec.add(rs.getString("description"));
vec.add(rs.getString("details"));
vec.add(rs.getString("quantity"));
vec.add(rs.getString("product_code"));
vec.add(rs.getString("reorder"));
data.addElement(vec);
}
}
我必须使用桌面模型吗?我只是想创建一个简单的表格,在数据库中显示我的搜索结果。有没有办法解决这个问题,而无需进入表模型并使用标准表构造函数。谢谢。