| Author |
Problem with JTextField
|
Anand Kumar Reddy
Greenhorn
Joined: Jul 01, 2008
Posts: 6
|
|
Hi, When i enter some text into my JTextField, the first character gets selected and will be over written with the second character. i.e., i want to enter -5, but, when i type '-' it gets selected and when i type '5', this over writes the '-' and only '5' remains in the text field. i tried the following code to fix this, but, is not working.... JTextField x = (JTextField) getEditorComponent(); if (null != x) { x.setSelectionStart(0); x.setSelectionEnd(x.getText().length()); x.requestFocus(); } Can some body help me how to solve this problem?
|
Cheers,
Anand.
Reach for the sky.. even if you have to stand on cactus!
|
 |
Steven Wall
Greenhorn
Joined: Nov 04, 2007
Posts: 22
|
|
|
Where is the code you posted located? Is it in an ActionListener registered with the JTextField? I haven't tested it, but it looks like that code would cause the behavior you are describing. Have you tried removing that code?
|
SCJP, SCWCD
|
 |
 |
|
|
subject: Problem with JTextField
|
|
|