Hello! I'm aware that you can fix the user input length into a JTextField by creating a PlainDocument class and using setDocument mehtod of the JTF. I need to do it without creating additional classes. I know another way.
jfield.addKeyListener(new KeyListener(){ public void keyPressed(KeyEvent ke){ if(MyJTextField.getText().length()) Toolkit.getDefaultToolkit().beep(); ke.consume(); } public void keyReleased(KeyEvent ke){keypressed(ke);} public void keyTyped(KeyEvent ke){}
But in this case when I select the text of the JTextField and press say Bar it doesnt delete. I wouldnt like to do additional for certain keys. And moreover in this case I get the java.lang.StackOverflowError exception.
Originally posted by fedai gandjaliyev: I was mistaken. It will not do. The example that you provided generates the "Testing$1.class" subclass together with the "Testing.class" class.
So does the example you gave.
This sounds like a homework assignment, and I think you are looking for a JFormattedTextField and a MaskFormatter.
After some pecan pie, you might want to cleanse your palatte with this tiny ad:
Gift giving made easy with the permaculture playing cards