• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

JTextField

 
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?
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • 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.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • 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!
 
I am not a spy. Definitely. Definitely not a spy. Not me. No way. But this tiny ad ...
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic