Hello Every One....
I am new in java and i am making a goods intake form for a company.. my question is when I load the data from database to a Jcombobox, the combobox always show the first record.. (displayed in the jcombobox)
I want an empty row at the to be displayed in the combobox at the top of the combobox and if user has selected any item then this empty space should disappear... (sorry for the language i dont have a very good comman over english)....
by the way the code is below
Code:private void setComboBoxForProduct(){
Products.getProductsForCombo();
cmbProductName = new JComboBox<Object>();
for(int i = 0; i<Products.productName.size(); i++){
cmbProductName.addItem(Products.productName.get(i));
}
cmbProductName.setEditable(true);
cmbProductName.addItemListener(this);
new ComboBoxAutoFill(cmbProductName);
}
//item listener on combobox
public void itemStateChanged(ItemEvent ie){
if(ie.getStateChange() == ItemEvent.SELECTED){
productID = Products.productID.get(cmbProductName.getSelectedIndex());
productType = Products.productType.get(cmbProductName.getSelectedIndex());
if(productType.equals("Chilled"))
rdoChilled.setSelected(true);
else if(productType.equals("Ambient"))
rdoAmbient.setSelected(true);
}
}
Thank you very much for viewing the code
Thanks
Usman
