Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

try this its work :

private void dchooser_departurePropertyChange(java.beans.PropertyChangeEvent evt) {
((JTextField)dchooser_departure.getDateEditor().getUiComponent()).setEditable(false); }

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top