문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

try this its work :

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top