Package java.text

Examples of java.text.AttributedString.addAttribute()


 
  public void test2(TestHarness harness)
  {
    harness.checkPoint("(AttributedCharacterIterator.Attribute)");
    AttributedString as = new AttributedString("ABCDEFGHIJ");
    as.addAttribute(TextAttribute.LANGUAGE, "English");
    as.addAttribute(TextAttribute.FOREGROUND, Color.red, 2, 4);
    AttributedCharacterIterator aci = as.getIterator();
    harness.check(aci.getRunLimit(TextAttribute.LANGUAGE), 10);
    harness.check(aci.getRunLimit(TextAttribute.FOREGROUND), 2);
    harness.check(aci.getRunLimit(TextAttribute.BACKGROUND), 10);
View Full Code Here


  public void test2(TestHarness harness)
  {
    harness.checkPoint("(AttributedCharacterIterator.Attribute)");
    AttributedString as = new AttributedString("ABCDEFGHIJ");
    as.addAttribute(TextAttribute.LANGUAGE, "English");
    as.addAttribute(TextAttribute.FOREGROUND, Color.red, 2, 4);
    AttributedCharacterIterator aci = as.getIterator();
    harness.check(aci.getRunLimit(TextAttribute.LANGUAGE), 10);
    harness.check(aci.getRunLimit(TextAttribute.FOREGROUND), 2);
    harness.check(aci.getRunLimit(TextAttribute.BACKGROUND), 10);
    aci.setIndex(2);
View Full Code Here

 
  public void test3(TestHarness harness)
  {
    harness.checkPoint("(Set)");   
    AttributedString as = new AttributedString("ABCDEFGHIJ");
    as.addAttribute(TextAttribute.LANGUAGE, "English");
    as.addAttribute(TextAttribute.FOREGROUND, Color.red, 2, 4);
    as.addAttribute(TextAttribute.BACKGROUND, Color.yellow, 3, 5);
    AttributedCharacterIterator aci = as.getIterator();
    Set set0 = new HashSet();
    Set set1 = new HashSet();
View Full Code Here

  public void test3(TestHarness harness)
  {
    harness.checkPoint("(Set)");   
    AttributedString as = new AttributedString("ABCDEFGHIJ");
    as.addAttribute(TextAttribute.LANGUAGE, "English");
    as.addAttribute(TextAttribute.FOREGROUND, Color.red, 2, 4);
    as.addAttribute(TextAttribute.BACKGROUND, Color.yellow, 3, 5);
    AttributedCharacterIterator aci = as.getIterator();
    Set set0 = new HashSet();
    Set set1 = new HashSet();
    set1.add(TextAttribute.LANGUAGE);
View Full Code Here

  {
    harness.checkPoint("(Set)");   
    AttributedString as = new AttributedString("ABCDEFGHIJ");
    as.addAttribute(TextAttribute.LANGUAGE, "English");
    as.addAttribute(TextAttribute.FOREGROUND, Color.red, 2, 4);
    as.addAttribute(TextAttribute.BACKGROUND, Color.yellow, 3, 5);
    AttributedCharacterIterator aci = as.getIterator();
    Set set0 = new HashSet();
    Set set1 = new HashSet();
    set1.add(TextAttribute.LANGUAGE);
    Set set2 = new HashSet();
View Full Code Here

  private void test1(TestHarness harness)
  {
    harness.checkPoint("addAttribute(AttributedCharacterIterator.Attribute, Object);");
    AttributedString as = new AttributedString("ABCDEFG");
    as.addAttribute(AttributedCharacterIterator.Attribute.LANGUAGE, Locale.ENGLISH);
    AttributedCharacterIterator aci = as.getIterator();
    harness.check(aci.getRunStart(AttributedCharacterIterator.Attribute.LANGUAGE) == 0);
    harness.check(aci.getRunLimit(AttributedCharacterIterator.Attribute.LANGUAGE) == 7);
   
    // test adding an attribute to a zero length string
View Full Code Here

    // test adding an attribute to a zero length string
    boolean pass = false;
    as = new AttributedString("");
    try
    {
      as.addAttribute(AttributedCharacterIterator.Attribute.LANGUAGE, "Unknown");
    }
    catch (IllegalArgumentException e)
    {
      pass = true;  
    }
View Full Code Here

    // test adding an attribute with a null value (permitted)
    pass = true;
    as = new AttributedString("123");
    try
    {
      as.addAttribute(AttributedCharacterIterator.Attribute.LANGUAGE, null);
    }
    catch (Exception e)
    {
      pass = false;  
    }
View Full Code Here

  private void test2(TestHarness harness)
  {
     harness.checkPoint("addAttribute(AttributedCharacterIterator.Attribute, Object, int, int);");
     AttributedString as = new AttributedString("ABCDEFG");
     as.addAttribute(AttributedCharacterIterator.Attribute.LANGUAGE, "Unknown", 2, 4);
     AttributedCharacterIterator aci = as.getIterator();
     harness.check(aci.getRunStart(AttributedCharacterIterator.Attribute.LANGUAGE), 0);
     harness.check(aci.getRunLimit(AttributedCharacterIterator.Attribute.LANGUAGE), 2);
     aci.next();
     aci.next();
View Full Code Here

     // if beginIndex < 0, there should be an IllegalArgumentException
     boolean pass = false;
     try
     {
       as = new AttributedString("ABC");
       as.addAttribute(AttributedCharacterIterator.Attribute.LANGUAGE, Locale.FRANCE, -1, 1);
     }
     catch (IllegalArgumentException e)
     {
       pass = true
     }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.