现在我的JTable里面有一组复选框··
我想做一个依赖性··就是说当其中一个别选择了·另外一个也必须得被选择····
请教··
急急急急急急急急急急急急急急!!!!!!急急急急急急急急急急急急急急!!!!!!急急急急急急急急急急急急急急!!!!!!急急急急急急急急急急急急急急!!!!!!在线等···

解决方案 »

  1.   


    //伪代码
    //---这是最蠢的方法,如果复选框少的话可以这样做。
    if(CheckBox_A.isSelected()){
       CheckBox_A.setSelected();
    }
    //一般是这样做
    ArrayList list = new ArrayList();
    list.add("你所有的BOX");
    for(int i=0;i<list.size();i++){
       //在这个里面写你的代码吧。
    }
      

  2.   

    我里面加的不是Check_BOX我加的是Boolean.FALSE或则Boolean.TRUE````
    谢谢你的回复···
    继续等····
      

  3.   

    if(CheckBox_A.isSelected()){
       CheckBox_A.setSelected();
    }
    这个就行
      

  4.   

    当然这样就可以了啊,这样就是在一个被选择以后,另一个也被选择的,不过要在checkbox上增加ChangeListenerif(CheckBox_A.isSelected()){
       CheckBox_B.setSelected();
    }
      

  5.   

    Object[][] cells = { {Boolean.FALSE, "必选", "", ""}, {Boolean.FALSE, 
    "可选", 
    "", ""}, {Boolean.FALSE, "必选", "", ""}, {Boolean.FALSE, 
    "可选", "", ""}, {Boolean.FALSE, "必选", "", ""}, 
    {Boolean.FALSE, "必选", "", ""}, {Boolean.FALSE, "必选", "", 
    ""}, {Boolean.FALSE, "必选", "", ""}, {Boolean.FALSE, "必选", 
    "", ""}, {Boolean.FALSE, "必选", "", ""}, {Boolean.FALSE, 
    "必选", "", ""}, {Boolean.FALSE, "必选", "", ""}, {Boolean.FALSE, "必选", "", 
    ""}, {Boolean.FALSE, "可选", "", ""}, {Boolean.FALSE, "可选", "", ""}, }; 
    String[] columnNames = { "选择", "重要级", "文件名", "说明", "" ,""}; // 获得升级MOdule并添加到JTable 
    // Object[][] getSetModule=objgetResponse.getModule(); 
    // String[] 
    // moduleName={"ID","name","seleect","depend","release","note"}; 
    DefaultTableModel model = new DefaultTableModel(cells, columnNames) {   public boolean isCellEditable(int row, int column) 
            { 
                TableModel model = jTable1.getModel();             if (column == 0) 
                { 
                    String checked = (String) model.getValueAt(row, column + 1); 
                    if (checked.equals("必选")) 
                    { 
                        return false; 
                    } 
                    return true; 
                } 
                return false; 
            } 
    public Class getColumnClass(int columnIndex) { 
    return columnIndex == 0 ? Boolean.class : String.class; 

    }; 
    ActionListener listener = new ActionListener() { 
    public void actionPerformed(ActionEvent event) { 
    int mode = 0; 

    }; jTable1 = new JTable(model); /** 
    * 获得用户选择项目 
    */ 
    jTable1.getModel().addTableModelListener(new TableModelListener() { 
    public void tableChanged(TableModelEvent e) { 
                    
    String getModule = ""; 
    String getValue = ""; TableModel model = jTable1.getModel(); 
    int count = model.getRowCount(); 
    for (int i = 0; i < count; i++) { 
    Boolean checked = (Boolean) model.getValueAt(i, 0); 
    if (checked.equals(Boolean.TRUE)) { 
    getModule = getModule + "" + String.valueOf(i) + ","; 
    getValue = getValue + "" 
    + (String) model.getValueAt(i, 1) + ","; 


    getAllModule = getValue; 
    System.out.println(""+getValue); } 
    }); 
    我的表格样式是这样的··· 
    都是Boolean类型的··· 
      

  6.   

    7楼的··能不能说的详细一点····有code最好····