How to fill a combobox from a matrix 2 dimensions in java -


I want to fill in a combo box with values ​​from a matrix 2 dimension in Java. For example, I have a string

[] [] s; With

  s [0] [0] = cp1; S [0] [1] = 30; S [0] [2] = 0; S [1] [0] = CP2; S [1] [1] = 50; S [1] [2] = 1500;  

I would fill a combo box with values ​​like cp1 and cp2 and

  On 1, it shows 30 and 0 values ​​in 2 text boxes and clicking on CP2 shows 50 and 1500 in these text boxes.  

I tried to code to fill Cambodia, but I did not succeed. Please, if you have any ideas please help me in advance thank you.

Create a class that stores each entry.

  class entry & lt; A, B & gt; {AA; BB;  

and set the toString method to use only the first field.

  @Override public string toString () {a.toString (); }}  

You can put these objects in the combobox, and they will only appear in the area of ​​ a .

You can then use

  B value = combobox.getItemAt (combobox.getSelectedIndex ()). B; 

This is a common solution, in your question it seems that you need more than two fields in the entry class, so just add those people.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -