Package javax.swing.text

Examples of javax.swing.text.MaskFormatter$CharCharacter


   */
  public MaskConverter(final String mask, final Class<?> type)
  {
    try
    {
      maskFormatter = new MaskFormatter(mask);
      maskFormatter.setValueClass(type);
      maskFormatter.setAllowsInvalid(true);
      maskFormatter.setValueContainsLiteralCharacters(true);
    }
    catch (ParseException e)
View Full Code Here


   */
  public MaskConverter(String mask, Class<?> type)
  {
    try
    {
      maskFormatter = new MaskFormatter(mask);
      maskFormatter.setValueClass(type);
      maskFormatter.setAllowsInvalid(true);
      maskFormatter.setValueContainsLiteralCharacters(true);
    }
    catch (ParseException e)
View Full Code Here

                   DefaultFormatterFactory.class);
    harness.check (field.getFormatter().getClass(), DefaultFormatter.class);
   

    harness.checkPoint ("setting formatter changes the text");
    MaskFormatter mask = null;
    DefaultFormatter nullFormatter = new DefaultFormatter();
    try
      {
        mask = new MaskFormatter ("UUUUUUU");
      }
    catch (ParseException pe)
      {
      }
    DefaultFormatterFactory factory =
View Full Code Here

  implements Testlet
{
 
  public void test(TestHarness harness)
  {
    MaskFormatter formatter = null;
    try
      {
        formatter = new MaskFormatter("RE'*B**KS");       
        // Default value checks
        harness.checkPoint("defaults");
        harness.check (formatter.getValueContainsLiteralCharacters());
        harness.check (!formatter.getAllowsInvalid());
        harness.check (formatter.getPlaceholder() == null);
        harness.check (formatter.getPlaceholderCharacter() == ' ');
        harness.check (formatter.getValidCharacters() == null);
        harness.check (formatter.getInvalidCharacters() == null);


        // Checks to see whether the appropriate characters are being used to pad
        harness.checkPoint("padding");
        formatter.setPlaceholder("MMMMMMMMM");
        formatter.setPlaceholderCharacter('$');
        harness.check (formatter.valueToString("RE"),"RE*BMMKS");
        formatter.setPlaceholder("8");
        harness.check (formatter.valueToString("RE"),"RE*B$$KS");
        formatter.setPlaceholder("12345");
        harness.check (formatter.valueToString("RE"),"RE*B5$KS");
       

        // Checks to see if valid output is produced
        harness.checkPoint("valid output");
        formatter.setMask("(###) ###-####");
        harness.check (formatter.valueToString("(555) 807-9090"),"(555) 807-9090");
        harness.check (formatter.stringToValue("(555) 807-9090"),"(555) 807-9090");
        formatter.setValueContainsLiteralCharacters(false);
        harness.check (formatter.stringToValue("(555) 807-9090"),"5558079090");
        boolean exception = false;
        try
          {
            harness.check (formatter.valueToString("(555) 807-9090"),"(555) 807-9090");
          }
        catch (ParseException pe)
          {
            exception = true;
          }
        harness.check (exception);                 
       
        // Checks to see if valid/invalid character sets work
        formatter = new MaskFormatter("T##'FA");       
        formatter.setInvalidCharacters("T");
        formatter.setValidCharacters("4");
        harness.check(formatter.valueToString("T44F4"), "T44F4");
        harness.check(formatter.stringToValue("T44F4"), "T44F4");
        exception = false;
        try
          {
            formatter.valueToString("T33F3");
          }
        catch (ParseException pe2)
          {
            exception = true;
          }
View Full Code Here

   
    private JFormattedTextField timeField;

    private void init() {
        try {
            MaskFormatter fmt = new MaskFormatter("##:##:##:##");
            Font fnt = new Font(Font.MONOSPACED, Font.BOLD, 24);
           
            fmt.setPlaceholderCharacter('0');
            timeField = new JFormattedTextField(fmt);
           
            timeField.setFont(fnt);
           
            add(new RecycleButton(this), new GridBagConstraints(0, 0, 1, 1, 0.0d, 1.0d, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
View Full Code Here

   */
  public MaskConverter(String mask, Class<?> type)
  {
    try
    {
      maskFormatter = new MaskFormatter(mask);
      maskFormatter.setValueClass(type);
      maskFormatter.setAllowsInvalid(true);
      maskFormatter.setValueContainsLiteralCharacters(true);
    }
    catch (ParseException e)
View Full Code Here

     */
    public DataField getqq_templateString() {
        if (qq_templateString == null) {
            // Mask type: MK_TEMPLATE
            try {
                MaskFormatter mf = new MaskFormatter("###-##-####");
                mf.setPlaceholderCharacter('_');
                mf.setValueContainsLiteralCharacters(false);
                qq_templateString = DataFieldFactory.newDataField("templateString", 31, mf);
            } catch (ParseException e) {
                qq_templateString = DataFieldFactory.newDataField("templateString", 31, TextData.class);
                Logger.getLogger("task.part.logmgr").error("Invalid mask specified for field: qq_templateString, a default field will be generated", e);
            }
View Full Code Here

     */
    public DataField getqq_viacode() {
        if (qq_viacode == null) {
            // Mask type: MK_TEMPLATE
            try {
                MaskFormatter mf = new MaskFormatter("###-##-####");
                mf.setPlaceholderCharacter('_');
                mf.setValueContainsLiteralCharacters(false);
                qq_viacode = DataFieldFactory.newDataField("viacode", 23, mf);
            } catch (ParseException e) {
                qq_viacode = DataFieldFactory.newDataField("viacode", 23, TextData.class);
                Logger.getLogger("task.part.logmgr").error("Invalid mask specified for field: qq_viacode, a default field will be generated", e);
            }
View Full Code Here

     */
    public DataField getqq_InnerGrid_mStringCharacterTemplate() {
        if (qq_InnerGrid_mStringCharacterTemplate == null) {
            // Mask type: MK_TEMPLATE
            try {
                MaskFormatter mf = new MaskFormatter("###-##-####");
                mf.setPlaceholderCharacter('_');
                mf.setValueContainsLiteralCharacters(false);
                qq_InnerGrid_mStringCharacterTemplate = DataFieldFactory.newDataField("mStringCharacterTemplate", 14, mf);
            } catch (ParseException e) {
                qq_InnerGrid_mStringCharacterTemplate = DataFieldFactory.newDataField("mStringCharacterTemplate", 14);
                Logger.getLogger("task.part.logmgr").error("Invalid mask specified for field: qq_InnerGrid_mStringCharacterTemplate, a default field will be generated", e);
            }
View Full Code Here

                    index++;
                    break;
            }
        }
        try {
            MaskFormatter aFormatter = new MaskFormatter(aBuffer.toString());
            aFormatter.setPlaceholderCharacter(placeHolderChar.charAt(0));
            aFormatter.setValueContainsLiteralCharacters(false);
            pField.setFormatterFactory(new DefaultFormatterFactory(aFormatter));
        }
        catch (Exception e) {
            _log.error("Could not set mask formatter to \"" + pForteCharacterTemplate + "\"", e);
        }
View Full Code Here

TOP

Related Classes of javax.swing.text.MaskFormatter$CharCharacter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.