Search code examples
javajcalendar

Java set non-editable? JCalender


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?


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.