Revision history [back]

click to hide/show revision 1
initial version

asked 2020-03-01 22:35:56 +0800

HotCat gravatar image HotCat

How do I set selectedIndex in this case

Here is my code ArrayList<cat> cats = new ArrayList<cat>(); cats.add(new Cat("Mary", "1")); cats.add(new Cat("Mark", "2")); cmbCat.setModel(new ListModelList(cats, true)); int i = cmbCat.getItemCount(); // i is 0 cmbCat.setSelectedIndex(0); cmbCat is a Combobox After I set the model of cmbCat, I want to set the SelectedIndex always fail. How can I achieve this? And why?

How do I set selectedIndex in this case

Here is my code ArrayList<cat> cats = new ArrayList<cat>(); cats.add(new Cat("Mary", "1")); cats.add(new Cat("Mark", "2")); cmbCat.setModel(new ListModelList(cats, true)); int i = cmbCat.getItemCount(); // i is 0 cmbCat.setSelectedIndex(0); cmbCat is a Combobox After I set the model of cmbCat, I want to set the SelectedIndex always fail. How can I achieve this? And why?

How do I set selectedIndex in this case

Here is my code code

  1. ArrayList<cat> cats = new ArrayList<cat>(); ArrayList<cat>();
  2. cats.add(new Cat("Mary", "1")); "1"));
  3. cats.add(new Cat("Mark", "2")); "2"));
  4. cmbCat.setModel(new ListModelList(cats, true)); true));
  5. int i = cmbCat.getItemCount(); // i is 0 cmbCat.setSelectedIndex(0); 0
  6. cmbCat.setSelectedIndex(0);

cmbCat is a Combobox After I set the model of cmbCat, I want to set the SelectedIndex always fail. How can I achieve this? And why?

How do I set selectedIndex in this case

Here is my code

  1. ArrayList<cat> cats = new ArrayList<cat>();

  2. ArrayList<cat>(); cats.add(new Cat("Mary", "1"));
  3. "1")); cats.add(new Cat("Mark", "2"));
  4. "2")); cmbCat.setModel(new ListModelList(cats, true));
  5. true)); int i = cmbCat.getItemCount(); // i is 0
  6. 0 cmbCat.setSelectedIndex(0);

cmbCat is a Combobox After I set the model of cmbCat, I want to set the SelectedIndex always fail. How can I achieve this? And why?

How do I set selectedIndex in this case

Here is my code

  • ArrayList<cat> cats = new ArrayList<cat>(); cats.add(new new ArrayList<cat>(); cats.add(new Cat("Mary", "1")); cats.add(new "1")); cats.add(new Cat("Mark", "2")); cmbCat.setModel(new cmbCat.setModel(new ListModelList(cats, true)); true)); int i = = cmbCat.getItemCount(); // i is 0 cmbCat.setSelectedIndex(0);

cmbCat is a Combobox After I set the model of cmbCat, I want to set the SelectedIndex always fail. How can I achieve this? And why?

How do I set selectedIndex in this case

Here is my code

  • ArrayList<cat> cats = new new ArrayList<cat>(); cats.add(new
  • cats.add(new Cat("Mary", "1")); cats.add(new "1"));
  • cats.add(new Cat("Mark", "2")); cmbCat.setModel(new "2"));
  • ListModelList(cats, true)); true));
  • int i = = cmbCat.getItemCount(); // i is 0 0
  • cmbCat.setSelectedIndex(0);

cmbCat is a Combobox After I set the model of cmbCat, I want to set the SelectedIndex always fail. How can I achieve this? And why?

How do I set selectedIndex in this case

Here is my code

  • ArrayList<cat> cats = new ArrayList<cat>();
  • cats.add(new Cat("Mary", "1"));
  • cats.add(new Cat("Mark", "2"));
  • ListModelList(cats, true));
  • int i = cmbCat.getItemCount(); // i is 0
  • cmbCat.setSelectedIndex(0);

cmbCat is a Combobox Combobox. After I set the model of cmbCat, I want to set the SelectedIndex always fail. How can I achieve this? And why?

How do I set selectedIndex in this case

Here is my code

  • ArrayList<cat>
    ArrayList<Cat> cats = new ArrayList<cat>(); 
  • ArrayList<Cat>();
  • cats.add(new Cat("Mary", "1"));
  • "1")); cats.add(new Cat("Mark", "2"));
  • "2")); ListModelList(cats, true));
  • true)); int i = cmbCat.getItemCount(); // i is 0
  • cmbCat.setSelectedIndex(0);
0 cmbCat.setSelectedIndex(0);

cmbCat is a Combobox. After I set the model of cmbCat, I want to set the SelectedIndex always fail. How can I achieve this? And why?

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More