Skip to content
Advertisement

Cannot enable grayed-out (.setEnabled(false)) JtextField or JTextArea

Unfortunately, I cannot turn on .setEnable() for a JTextField, or a JTextField (tried both). It keeps remaining gray, so users cannot type. Please help me out.

Details: taTwo can be either a JTextField or JTextArea but any I try cannot be enabled. It should be disabled for A but should be enabled for B, so if user choose A he/she can NOT enter a value in taTwo field, but if the user choose B he/she can write in taTwo.

The method is the following:

JavaScript

Advertisement

Answer

In your actionPerformed method, you are creating a new JTextField which you are not adding to your GUI. I presume that you have another variable named taTwo somehere in the code that you did not post. You are not changing that variable inside the actionPerformed method. Try removing this line of your code:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement