Discussion Locked

May editmask be used with jTextFields?

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

The aim is to use an editmask to force that only valid dates are entered (typed) into the field. This could be done by linking a jDbTextField to a column of a QueryDataSet and then setting the editmask for this column. However the date involved inthis case is not a column of a table. It is a date that will be used to make decisions about the processing. jTextField itself has no editmask property. If editmask cannot be used is there some other way. The format method of DateFormat is usedto produce a string from a valid date. The parse method of DateFormat is used to produce a valid date from a string. Neither of them seems to serve as an editmask during data capture.

Help will be appreciated.

3 replies

by c1980

You could make it simple by catching the input on the TextBox BeforeUpdate event, (Access) or the TextBox Validation Event in VB.

Private Sub Text6_BeforeUpdate(Cancel As Integer)

If Not IsDate(TextBox1.Text) then
MsgBox "Wrong Date Input"
Cancel=True
End If
End Sub

You can still use an editmask.
Go to the Code widow of the form, (in Access - View|Code), and pick the text box out of the left drop down and if the event isn't then already showing in the code window then pick it fromthe right drop down.

by mike

Thanks for your response. I should have made it clear that the question concerns the use of Java Swing classes. So although the equivalent events exist, I can't find an isDate method.

by mike

To CClint:

Thanks for your quick response. I need to clarify the question. I'm working with Java. JTextField is one of the Java Swing classes.
I understand your response to be in the context of Visual Basic.

This discussion is closed to new replies.