How To Enable/Disable JTextField At Runtime
KonTikiNov 15 2012 — edited Nov 26 2012I can disable/enable JTextFields before runtime by the usual
myTextField.setEnabled(false/true);
But what I really want to do is to have the code itself decide whether to enable or disable certain fields depending on selections made at other JComboBoxes.
The idea is to avoid a situation whereby a user enters data into a field that is not relevant to the other selections that they have already made on the GUI.
However, if the user changes his/her mind on which primary selection they want to make at the JComboBox, the disabled fields may be re-enabled for the new selection.
I have coded it so that my GUI program decides to enable or not on the basis of the selection made at the first JComboBox.
But that does not work - the redundant fields are not greyed out for corresponding selections.
I have coded it so that the additional fields are initially disabled, then re-enabled for certain selections from the primary JComboBox.
This does not work either - the JTextFields remain greyed out regardless !
What do I do ?
I use Java SE 1.7 .
Edited by: KonTiki on 15-Nov-2012 14:00