这是我这里的代码,变量bq是一个名为basicQuery的自定义类,它返回一个javadb连接…autocompletedecorator是swingx库中用于实现自动完成函数的类…这段代码当rus运行了大约3次,但在那之后,它会一直冻结,并在一段时间后抛出内存不足异常!我找不到问题所在。有人能帮我吗?另外,如果您需要代码的其他部分,请告诉我!
<> >
private void initcombos()。
{
resultset r=bq.executequery(“从产品中选择productid,productname”);
cmbpproductID.removeActionListener(this);
cmbpproductID.removeActionListener(this);
尝试
{
cmbpproductID.removeAllitems();
cmbpproductname.removeAllitems();
cmbcodes.removeAllitems();
字符串S1;
而(r n)()
{
s1=r.getString(1).trim();
cmb产品ID.additem(s1);
cmbcodes.additem(s1);
cmbproductname.additem(r.getString(2.trim());
}
R闭包();
cmbpproductID.addActionListener(this);
cmbproductname.addactionListener(this);
自动完成ecorator.decorate(cmbproductid);
自动完成ecorator.decorate(cmbproductname);
}
catch(异常X)
{
joptionpane.showmessagedialog(这是“设置组合框时出错”+x);
}
}
< /代码>
private void initCombos()
{
ResultSet r=bq.executeQuery("select productID,productName from products");
cmbProductID.removeActionListener(this);
cmbProductID.removeActionListener(this);
try
{
cmbProductID.removeAllItems();
cmbProductName.removeAllItems();
cmbCodes.removeAllItems();
String s1;
while(r.next())
{
s1=r.getString(1).trim();
cmbProductID.addItem(s1);
cmbCodes.addItem(s1);
cmbProductName.addItem(r.getString(2).trim());
}
r.close();
cmbProductID.addActionListener(this);
cmbProductName.addActionListener(this);
AutoCompleteDecorator.decorate(cmbProductID);
AutoCompleteDecorator.decorate(cmbProductName);
}
catch(Exception x)
{
JOptionPane.showMessageDialog(this,"Error setting up ComboBoxes "+x);
}
}