本帖最后由 Evenque 于 2010-11-02 17:18:54 编辑

解决方案 »

  1.   

    只更改了editor,没有更改renerer,也就是非编辑状态下的渲染方式。或者改写model的getValueAt方法,改变默认的显示数据。
      

  2.   

    我另外的代码里面用了渲染。
    [code=Java] class DataSourceCellRenderer extends DefaultTableCellRenderer {
    private static final long serialVersionUID = 1L; public Component getTableCellRendererComponent(JTable table,
    Object value, boolean isSelected, boolean hasFocus, int row,
    int column) {
    super.getTableCellRendererComponent(table, value, isSelected,
    hasFocus, row, column);
    if (column == 0) {
    setHorizontalAlignment(SwingConstants.CENTER);
    return this;
    } else {
    // if(row == 6 && column == 1){
    // if(((JPasswordField)getCelleditofPassword().getComponent()).getPassword()!=null
    // && ((JPasswordField) getCelleditofPassword().getComponent()).getPassword().toString().length() > 0)
    // this.setText("******");
    // }
    setHorizontalAlignment(SwingConstants.LEFT);
    return this;
    }
    }
    }code]
    注释掉的那段代码不起作用,在没有输入密码的时候也显示×号
    请问我怎么才能设置密码框在初始化没有编辑的时候是空的呢,输入密码后,结束编辑状态,显示几个×号?