문제

해시 맵은 키와 값 (XML 파싱 결과)을 포함합니다.해시 맵은 키가 문자열이고 값이 벡터 인 방식에있는 것들이 포함됩니다.키는 벡터 또는 벡터의 벡터 또는 mutiple 값에 단일 값을 가질 수 있습니다.

내 질문은 다음과 같습니다.

이 해시 맵은 JTable에 넣어야하므로 키가 단일 값이 있으면 텍스트 상자에 넣으십시오.여러 값이있는 경우 해당 테이블의 행에 ComboBox를 삽입하십시오.

이 문제에 대한 스윙 코드가 필요합니다

도움이 되었습니까?

해결책

Not code but steps that can help you..

  1. Create a Table.
  2. 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.
  3. Repeat step 2 for all hashmap keys.

References that can help you:-

  1. Adding row in table
  2. Adding comboBox in table
  3. JTable add/remove rows to custom table model (updating table display)

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top