maskformatter

Applying a MaskFormatter to a column in my JTable, but the mask is only used on the first cell I edit in the column

為{幸葍}努か 提交于 2020-01-06 18:25:31
问题 ////DOB column formats to dd/mm/yy TableColumn dobColumn = table.getColumnModel().getColumn(3); DateFormat df = new SimpleDateFormat("dd/mm/yy"); JFormattedTextField tf = new JFormattedTextField(df); tf.setColumns(8); try { MaskFormatter dobMask = new MaskFormatter("##/##/##"); dobMask.setPlaceholderCharacter('0'); dobMask.install(tf); } catch (ParseException ex) { Logger.getLogger(DisplayStudents.class.getName()).log(Level.SEVERE, null, ex); } dobColumn.setCellEditor(new DefaultCellEditor(tf