Membatasi jumlah karakter inputan - Java - Publisher - Royz Rambo
Ilham Penta
Site menu
Section categories
My articles [6]
Java [14]
Java Programming
Flash [6]
Flash
URL web dan Tutorial [29]
Petualangan [1]
Our poll
Rate my site
Total of answers: 19
Statistics

Total online: 2
Guests: 2
Users: 0
Login form
Main » Articles » Java

Membatasi jumlah karakter inputan

txtTglAnda.setDocument(new BatasiInput((byte)2).getFilter());
 

txtTglPasangan.setDocument(new BatasiInput((byte)2).getFilter());


class BatasiInput{

byte length;
PlainDocument filter;

private BatasiInput(byte length) {
this.length = length;
}

public PlainDocument getFilter(){
filter = new javax.swing.text.PlainDocument(){
public void insertString(int offs, String str, AttributeSet a)throws BadLocationException{
int ab = txtTglAnda.getText().length();
if(ab < length){
super.insertString(offs, str, a);
}
}
};
return filter;
}

}
Category: Java | Added by: penta (2010-09-24)
Views: 377 | Rating: 0.0/0
Total comments: 0
Name *:
Email *:
Code *:
Search
Site friends
  • Create a free website
  • Copyright Penta.Inc © Powered By: Senjapala