java - How do I properly use an array with JComboBox? -
I am running with my code in some code which is about implementing an ArrayList in JComboBox. I'm able to do this by using code like "codeList.addItem (selectItem)" code; without an array The one I am trying to accomplish is to use a new list to send new information in the second part of the GII so that I use that array to save and load data while the user starts a GUI. Can do Question: How do I use an array with JComboBox? I have seen some tutorials, but I do not think get the combobox to update with elements in the array. I am making a mistake somewhere, if you can help, I would be really grateful.) // This piece of code is the main Java file; Order is in OrderSystem.java. // Retrieves the selected data from JComboBox (one from a separate) and adds it to the array list. Now, inside OrderSystem.Java: creates an ArrayList and JComboBox // Sets and Gates Thanks! Try it:
order system order = new order system (); Outerst & lieutenant; String & gt; List = order.getArrayList ();
JComboBox & lt; String & gt; Test = room.getRoomType (); String selected item = (string) Test.getSelectedItem (); List.add (sealed ctedItem);
ArrayList < String & gt; List = New Arrestist & lt; String & gt; (); JComboBox & LT; Object & gt; RoomList; ... setComboBox (new JComboBox & lt;> (list.toArray ()));
Public array list & lt; String & gt; GetArrayList () {Return List; } Public Zero SetArealist (Arlist & Lt; String & gt; List) {this.list = list; }
comboBox.setModel (New DefaultComboBoxModel &
Comments
Post a Comment