Package javax.swing.text

Examples of javax.swing.text.SimpleAttributeSet.addAttribute()


    // add an attribute that already exists, same value
    s.addAttribute("X1", "Y1");
    harness.check(s.getAttributeCount(), 1);
   
    // add an attribute that already exists, different value
    s.addAttribute("X1", "YY1");
    harness.check(s.getAttribute("X1"), "YY1");
    harness.check(s.getAttributeCount(), 1);
   
    // add an attribute that exists in the resolve parent, same value
    SimpleAttributeSet sParent = new SimpleAttributeSet();
View Full Code Here


    harness.check(s.getAttribute("X1"), "YY1");
    harness.check(s.getAttributeCount(), 1);
   
    // add an attribute that exists in the resolve parent, same value
    SimpleAttributeSet sParent = new SimpleAttributeSet();
    sParent.addAttribute("X2", "Y2");
    s.setResolveParent(sParent);
    harness.check(s.getAttributeCount(), 2);
   
    // this adds to s, not sParent
    s.addAttribute("X2", "Y2");
View Full Code Here

  {
    h.checkPoint("SimpleAttributeSet");
    SimpleAttributeSet sas = new SimpleAttributeSet();
    try
      {
        sas.addAttribute("key", null);
        h.fail("SimpleAttributeSet must not accept null value");
      }
    catch (NullPointerException ex)
      {
        h.check(true);
View Full Code Here

  {
    SimpleAttributeSet set1 = new SimpleAttributeSet();
    SimpleAttributeSet set2 = new SimpleAttributeSet();
   
    set1.addAttribute("hello", "hello");
    set2.addAttribute("hello", "goodbye");

    //attempt to remove a set that doesn't match
    set1.removeAttributes(set2);

    harness.check(set1.containsAttribute("hello", "hello"));
View Full Code Here

    MutableAttributeSet a2 = new SimpleAttributeSet();
    MutableAttributeSet a3 = new SimpleAttributeSet();

    a1.addAttribute(StyleConstants.NameAttribute, "MY_FIRST");
    a2.addAttribute(StyleConstants.NameAttribute, "MY_SECOND");
    a3.addAttribute(StyleConstants.NameAttribute, "MY_MIDDLE");

    ElementSpec s1 = new ElementSpec(a1, ElementSpec.ContentType,
                                     "1".toCharArray(), 0, 1);
    ElementSpec s2 = new ElementSpec(a2, ElementSpec.ContentType,
                                     "2".toCharArray(), 0, 1);
View Full Code Here

    harness.check(s2.getResolveParent(), null);
    harness.check(s2.getAttribute("X1"), "Y1");
   
    SimpleAttributeSet ss = new SimpleAttributeSet();
    ss.setResolveParent(s);
    ss.addAttribute("X2", "Y2");
   
    SimpleAttributeSet s3 = new SimpleAttributeSet(ss);
    harness.check(s3.isEmpty(), false);
    harness.check(s3.getResolveParent(), s);
    harness.check(s3.getAttribute("X1"), "Y1");
View Full Code Here

  {
    harness.checkPoint("getAttribute()");
     
    SimpleAttributeSet s = new SimpleAttributeSet();
    harness.check(s.getAttribute("X1"), null);
    s.addAttribute("X1", "Y1");
    harness.check(s.getAttribute("X1"), "Y1");
     
    // add an attribute that exists in the resolve parent, same value
    SimpleAttributeSet sParent = new SimpleAttributeSet();
    sParent.addAttribute("X2", "Y2");
View Full Code Here

    s.addAttribute("X1", "Y1");
    harness.check(s.getAttribute("X1"), "Y1");
     
    // add an attribute that exists in the resolve parent, same value
    SimpleAttributeSet sParent = new SimpleAttributeSet();
    sParent.addAttribute("X2", "Y2");
    s.setResolveParent(sParent);
    harness.check(s.getAttribute("X2"), "Y2");
     
    // this adds to s, not sParent
    s.addAttribute("X2", "YY2");
View Full Code Here

    s1.addAttribute("X2", "Y2");
    harness.check(!s1.equals(s2));
   
    // clone a set with a resolve parent
    SimpleAttributeSet s3 = new SimpleAttributeSet();
    s3.addAttribute("A1", "B1");
    s1.setResolveParent(s3);
    s2 = (SimpleAttributeSet) s1.clone();
    harness.check(s1.equals(s2));
    s3.addAttribute("A1", "BB");
    harness.check(s1.equals(s2));
View Full Code Here

    SimpleAttributeSet s3 = new SimpleAttributeSet();
    s3.addAttribute("A1", "B1");
    s1.setResolveParent(s3);
    s2 = (SimpleAttributeSet) s1.clone();
    harness.check(s1.equals(s2));
    s3.addAttribute("A1", "BB");
    harness.check(s1.equals(s2));
    s1.addAttribute("Y1", "-");   
    harness.check(!s1.equals(s2));   
   
  }
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.