2014-03-24 3 views
0

배열에서 테이블을 만들 때 첫 번째 열은 배열에있는 값으로 채우고 두 번째 열은 배열 색인 값이있는 ckeckBoxes로 채 웁니다. 내가 선택한 확인란의 이름을 검색해야합니다. 아래 코드는 제발, 아무도 도와 줄 수 있니?gwt 자바에서 확인란의 이름을 얻으십시오

도움 주셔서 감사합니다.

public class AddDoodlePart3 extends Composite { 

MainView main = new MainView(); 
FlexTable table= new FlexTable(); 
VerticalPanel ab = new VerticalPanel(); 
HorizontalPanel hor = new HorizontalPanel(); 
InlineLabel lb = new InlineLabel("tette"); 
CheckBox ck ; 
TextBox orario = new TextBox(); 
Button btn = new Button("Inserisci"); 
int culo; 

public AddDoodlePart3(String det, ArrayList<String> listDate){ 
    initWidget(this.ab); 
    this.ab.add(lb); 
    System.out.println(det+listDate.size()); 
    table.setText(0, 0, " "); 
    table.setText(0, 1, "Opzione"); 
    table.setText(0, 2, " "); 
    System.out.println("1"); 

    for(int i=0;i<listDate.size();i++){ 
     System.out.println(i); 
     this.ck = new CheckBox(""+i); 
     table.setWidget(i, 0, ck); 

     table.setText(i, 1, listDate.get(i)); 
     ck.addClickHandler(new ClickHandler() { 
      @Override 
      public void onClick(ClickEvent event) { 

       boolean checked = ((CheckBox) event.getSource()).getValue(); 
       Window.alert("It is " + (checked ? "" : "not ") + "checked "+ culo); 
      } 
      }); 
    } 

    this.ab.add(table); 
    this.hor.add(orario); 
    this.hor.add(btn); 
    this.ab.add(hor); 
    btn.addClickHandler(new ClickHandler() { 

     @Override 
     public void onClick(ClickEvent event) { 

     // System.out.println(culo); 


     } 
    }); 
} 

}

답변

0

는 이러한 목적을 위해 데이터 그리드 위젯을 사용해야합니다. 예를 들어 GWT Showcase을 참조하십시오. 이 DataGrid를 구현하는 방법을 보려면 소스 코드 링크를 클릭하십시오.

DataGrid에 SelectionModel을 설정할 수 있습니다. 사용자의 경우 MultiSelectionModel이 필요합니다. 그런 다음 선택한 항목의 목록을 가져 오는 것은 다음과 같이 쉽습니다.

selectionModel.getSelectedSet(); 
관련 문제