Using the clipboard paste function with a JMaskEdit control

Article ID: 1057
Last updated: 02 Feb, 2008
Article ID: 1057
Last updated: 02 Feb, 2008
Revision: 1
Views: 7516
Posted: 16 Sep, 1998
by Dean J.
Updated: 02 Feb, 2008
by Dean J.
Problem


Using the paste keyboard command (Ctrl-V) makes it possible for a user to paste characters into a JMaskEdit field that should not be allowed. An exception is thrown when the user presses the Enter key due to the invalid characters in the mask control.


Cause


The current JMaskEdit-based controls do not guard against the pasting of invalid characters from the clipboard buffer into a mask field. Only characters entered directly from the keyboard are checked.


Action


The following modifications to the JMaskEdit control will allow the user to use the paste (Ctrl-V) keyboard sequence with a mask-controlled field.

Change the paste(int at, String string) method of the JMaskEdit class and add an additional paste method as follows:

  1. Find the JMaskEdit.java file in StudioJcom oguewavelendjfcmaskv2_0
  2. Change the file to look like this:
    public boolean paste(int at, String string) {
    for (int i=0; i
  3. Recompile the file.
This article was:   Helpful | Not helpful
Report an issue
Article ID: 1057
Last updated: 02 Feb, 2008
Revision: 1
Views: 7516
Posted: 16 Sep, 1998 by Dean J.
Updated: 02 Feb, 2008 by Dean J.

Others in this category