JCOMBOBOBOX로 JTABLE 행에 여러 값을 저장하는 방법
-
15-11-2019 - |
문제
해시 맵은 키와 값 (XML 파싱 결과)을 포함합니다.해시 맵은 키가 문자열이고 값이 벡터 인 방식에있는 것들이 포함됩니다.키는 벡터 또는 벡터의 벡터 또는 mutiple 값에 단일 값을 가질 수 있습니다.
내 질문은 다음과 같습니다.
이 해시 맵은 JTable에 넣어야하므로 키가 단일 값이 있으면 텍스트 상자에 넣으십시오.여러 값이있는 경우 해당 테이블의 행에 ComboBox를 삽입하십시오.
이 문제에 대한 스윙 코드가 필요합니다
해결책
Not code but steps that can help you..
- Create a Table.
- Every time adding a new row check for the hashmap value and if it is a single value add textbox to that cell or add comboBox.
- Repeat step 2 for all hashmap keys.
References that can help you:-
다른 팁
You can make a HashMap<String, Vector<ValueType>> which maps a String key to a Vector. In this case, even a single value will be stored in a Vector, and when you add the first element for a hash key, you have to make a vector, add the element to it, and put the vector with the key. Subsequently you can just add to the vector. For display, determine if the Vector has 1 or more elements to decide which UI to use.