You can also write a simple listener:
addKeyListener(new KeyAdapter() {
public void keyTyped(KeyEvent e) {
if(e.getKeyChar() == '.') {
e.consume();
}
}
});
Edit:
As @HovercraftFullOfEels mentioned in the comments, you better use DocumentFilter, see this answer for a good explanation and refer for the tutorial.
Edit 2:
You can try to MaskFormatter:
MaskFormatter formatter = new MaskFormatter(/*Check out the link*/);
JFormattedTextField tf = new JFormattedTextField(formatter );