텍스트 필드를 JFormattedTextField로 생성


try {

MaskFormatter format = new MaskFormatter("####-##-##");

sheif_Life_TextField = new JFormattedTextField(format);

sheif_Life_TextField.setBounds(100, 55, 116, 21);

stock_contentPane.add(sheif_Life_TextField);

sheif_Life_TextField.setColumns(10);

} catch (ParseException e1) {

// TODO 자동 생성된 catch 블록

e1.printStackTrace();

}


MaskFormatter로 형식을 지정해주고 실행해보면


텍스트필드에 - - 이렇게만적혀있다.


그냥 연도,월,일 순으로 20000101입력한다면


2000-01-01 이렇게 완성된다.


자신이 정한 포맷형식을 벗어나지않는다


2000010101 입력이 안된다는 말이다.



블로그 이미지

왕왕왕왕

,