日期:2014-05-20  浏览次数:20825 次

JCheckBox数组如何获得里面被选中的值
Object[][] cells = {  
  {Boolean.FALSE, "必选","",""},  
  {Boolean.FALSE, "可选","",""},  
  {Boolean.FALSE, "必选","",""},  
  {Boolean.FALSE, "可选","",""},  
  {Boolean.FALSE, "必选","",""},};  
  String[] columnNames = {"选择","重要级","文件名","说明"};  


  DefaultTableModel model = new DefaultTableModel(cells, columnNames) {  
  public Class getColumnClass(int columnIndex)  
  {  
  return columnIndex == 0 ? Boolean.class : String.class;  
  }  
  };

------解决方案--------------------
JS,如果checkbox同名的话,可以做为数组传递到后端,后端可以用request.getParameterValues("参数名")取得多值String[]数组;
------解决方案--------------------
添加ItemListener,重载itemStateChanged(ItemEvent e) 处理,在这之中将想要返回的值传递给后台处理对象