On May 12, 4:29 am, "* ^ *" <[email protected]> wrote: > I have done the Swing homework, but am now attempting it again with > the GUI Builder. I am at the comboBox stage. > > I have written code in the source that: Seek the image directory. > Extract all image files' name. Then remove its file extension. Finally > use the resulting String[] to populate the comboBox. Below are the > relevant code fragments: > // Returns path of image directory > getImageDirectory(); > // Returns images name from image directory > getImagesName(); > // Remove the file extension from images name > removeFileExtension(); > // Initialise comboBox with teams and set initial team. > private void populateTeams(){ > String[] teams=removeFileExtension(getImagesName()); > jComboBox1.removeAllItems(); > for(String team : teams) { > jComboBox1.addItem(team); > } > jComboBox1.setSelectedIndex(0); > > } > > But all the above codes does not affect any change in the comboBox. It > still shows <item 1>.. <Item 4>. Just in case anyone interested to know, the GUI Builder generated comboBox is backed by a comboBoxModel. The default values can be changed in the model property.
Takes me a while to do. Not as easy as I initially thought. > > Any ideas how I can overcome this? Thank you. --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en -~----------~----~----~----~------~----~------~--~---
