Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextField  RSS feed

 
Carey Payette
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an application that enables/disables fields on a JFrame form.
Upon startup the JTextField are disabled using:
jtf.setEnabled(false);
Once needed the field is enabled using:
jtf.setEnabled(true);
The problem I am experiencing is that the first time the text field is enabled, I cannot see the highlight or the cursor. I can "pretend" to highlight the text and am able to change the text so it is getting focus and it is editable.
Once the field is disabled then enabled again (form is reset) for the second time, the highlight and the cursor work fine.
I tried enabling/disabling/enabling/disabling and the first time I tried to maintain the text in the field, the same problem occurred.
The exact same functions are called on the form when it is loaded as well as when it is reset.
This is only happening on JTextField components. The JRadioButtons and JComboBoxes are working fine every time.
Has this happened to anyone else?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have not had that problem myself, but you might try myTextField.repaint() after you enable it and see if that helps.
Good luck.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you say what look & feel, platform, java version, and swing version( if applicable ) are you using? Any of these could impact the problem. Using Metal L&F, Windows L&F, or Motif L&F on a Windows NT machine with Java 1.3 I had no problems like you described...

-Nate
 
Carey Payette
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using the JDK1.3.1, using the regular javax.swing.*, I am not using a layout, I am absolutely positioning the fields using setBounds on the components. Still not sure why this problem is happening!
repaint() didn't work, but it was worth a shot
Thanks for the suggestions!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!