我从插入 2D 向量和 String[] 作为标题的 JTable 返回错误...
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);
}
}
我必须使用表格模型吗?我只是想创建一个简单的表来显示我在数据库中的搜索结果。有没有办法在不进入表模型并使用标准表构造函数的情况下解决这个问题。谢谢你。