• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

JTextField

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
reply
    Bookmark Topic Watch Topic
  • New Topic