Is there a way to set a textfield in Java to non-editable? I don't mean not enabled as I want the user to be able to insert values by using JCalender but not to be able to enter values manually?
Asked
Active
Viewed 3,735 times
2 Answers
2
Yes. But I think you are talking about something like JDateChooser
:
JDateChooser dateChooser = new JDateChooser();
dateChooser.getDateEditor().setEnabled(false);
Doing this you avoid that users input manually the date through the editor, they must to choose the date by the graphical chooser.

carexcer
- 1,407
- 2
- 15
- 27
1
try this its work :
private void dchooser_departurePropertyChange(java.beans.PropertyChangeEvent evt) {
((JTextField)dchooser_departure.getDateEditor().getUiComponent()).setEditable(false);
}

faisal khan
- 47
- 1
- 1
- 3