Package javax.swing.text

Examples of javax.swing.text.SimpleAttributeSet


   */
  public void test(TestHarness harness)     
  {
    harness.checkPoint("getAttributeCount()");
     
    SimpleAttributeSet s = new SimpleAttributeSet();
    harness.check(s.isEmpty(), true);

    s.addAttribute("X1", "Y1");
    harness.check(s.isEmpty(), false);
   
    s.removeAttribute("X1");
    harness.check(s.isEmpty(), true);
   
    // add an attribute that exists in the resolve parent, same value
    SimpleAttributeSet sParent = new SimpleAttributeSet();
    s.setResolveParent(sParent);
    harness.check(s.isEmpty(), false);
   
    sParent.addAttribute("X2", "Y2");
    harness.check(s.isEmpty(), false);
  }
View Full Code Here


   */
  public void test(TestHarness harness)     
  {
    harness.checkPoint("removeAttribute()");
   
    SimpleAttributeSet s = new SimpleAttributeSet();
    // remove an attribute that doesn't exist
    s.removeAttribute("X1");
    s.addAttribute("X1", "Y1");
    harness.check(s.getAttribute("X1"), "Y1");
    // remove another attribute that doesn't exist
    s.removeAttribute("X2");
    harness.check(s.getAttributeCount(), 1);
    // remove an existing attribute
    s.removeAttribute("X1");
    harness.check(s.getAttribute("X1"), null);
   
    SimpleAttributeSet sParent = new SimpleAttributeSet();
    sParent.addAttribute("XX", "YY");
    s.setResolveParent(sParent);
    harness.check(sParent.getAttributeCount(), 1);
    s.removeAttribute("XX");
    harness.check(sParent.getAttribute("XX"), "YY");
   
    // try null attribute key
    boolean pass = false;
    try
      {
View Full Code Here

   */
  public void test(TestHarness harness)     
  {
    harness.checkPoint("containsAttribute()");
   
    SimpleAttributeSet s = new SimpleAttributeSet();
    harness.check(s.containsAttribute("X1", "Y1"), false);
    s.addAttribute("X1", "Y1");
    harness.check(s.containsAttribute("X1", "Y1"), true);
    harness.check(s.containsAttribute("X1", "Y2"), false);
    harness.check(s.containsAttribute("X2", "Y1"), false);
       
    // check with resolve parent
    SimpleAttributeSet sParent = new SimpleAttributeSet();
    sParent.addAttribute("X2", "Y2");
    s.setResolveParent(sParent);
    harness.check(s.containsAttribute("X1", "Y1"), true);
    harness.check(s.containsAttribute("X2", "Y2"), true);
    s.addAttribute("X2", "ZZ");
    harness.check(s.containsAttribute("X2", "ZZ"), true);
View Full Code Here

   */
  public void test(TestHarness harness)     
  {
    harness.checkPoint("getResolveParent()");
     
    SimpleAttributeSet s = new SimpleAttributeSet();
    harness.check(s.getResolveParent(), null);

    SimpleAttributeSet sParent = new SimpleAttributeSet();
    s.setResolveParent(sParent);
    harness.check(s.getResolveParent(), sParent);

    s.removeAttribute(AttributeSet.ResolveAttribute);
    harness.check(s.getResolveParent(), null);
View Full Code Here

   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)     
  {
    harness.checkPoint("isEqual()");
    SimpleAttributeSet s = new SimpleAttributeSet();
    harness.check(s.isEqual(SimpleAttributeSet.EMPTY), true);
    harness.check(SimpleAttributeSet.EMPTY.isEqual(s), true);
   
    SimpleAttributeSet s2 = new SimpleAttributeSet();
    s2.addAttribute("XX", "YY");
   
    harness.check(s.isEqual(s2), false);
   
    boolean pass = false;
    try
View Full Code Here

  }
 
  public void test1(TestHarness harness)
  {
    harness.checkPoint("(AttributeSet)");
    SimpleAttributeSet s = new SimpleAttributeSet();
    s.addAttribute("A", "1");
    s.addAttribute("B", "2");
    s.addAttribute("C", "3");
    s.addAttribute("D", "4");
    s.addAttribute("E", "5");
    s.addAttribute("F", "6");
    harness.check(s.getAttributeCount(), 6);
   
    SimpleAttributeSet ss = new SimpleAttributeSet();
    ss.addAttribute("A", "1");
    ss.addAttribute("C", "3");
    ss.addAttribute("E", "5");
   
    s.removeAttributes(ss);
    harness.check(s.getAttributeCount(), 3);
    harness.check(s.getAttribute("B"), "2");
    harness.check(s.getAttribute("D"), "4");
    harness.check(s.getAttribute("F"), "6");
   
    SimpleAttributeSet sss = new SimpleAttributeSet();
    ss.addAttribute("B", "XXX");
    s.removeAttributes(sss);   
    harness.check(s.getAttributeCount(), 3);
    harness.check(s.getAttribute("B"), "2");
    harness.check(s.getAttribute("D"), "4");
    harness.check(s.getAttribute("F"), "6");
   
    // check for remove of the resolve parent
    SimpleAttributeSet s2 = new SimpleAttributeSet();
    SimpleAttributeSet sParent = new SimpleAttributeSet();
    s2.setResolveParent(sParent);
    harness.check(s2.getResolveParent(), sParent);
    SimpleAttributeSet s3 = new SimpleAttributeSet();
    s3.setResolveParent(sParent);
    s2.removeAttributes(s3);
    harness.check(s2.getResolveParent(), null);

    // try null
    boolean pass = false;
View Full Code Here

  }

  public void test2(TestHarness harness)
  {
    harness.checkPoint("(Enumeration)");
    SimpleAttributeSet s = new SimpleAttributeSet();
    s.addAttribute("A", "1");
    s.addAttribute("B", "2");
    s.addAttribute("C", "3");
    s.addAttribute("D", "4");
    s.addAttribute("E", "5");
    s.addAttribute("F", "6");
    harness.check(s.getAttributeCount(), 6);
   
    Vector v = new Vector();
    v.add("B");
    v.add("D");
    v.add("F");
    Enumeration e = v.elements();
    s.removeAttributes(e);
    harness.check(s.getAttributeCount(), 3);
    harness.check(s.getAttribute("A"), "1");
    harness.check(s.getAttribute("C"), "3");
    harness.check(s.getAttribute("E"), "5");
   
    // try an enumeration with null in it
    boolean pass = false;
    try
      {
        v.clear();
        v.add(null);
        e = v.elements();
        s.removeAttributes(e);   
      }
      catch (NullPointerException ex)
      {
        pass = true;
      }
    harness.check(pass);
   
    // try a null enumeration
    pass = false;
    try
      {
        s.removeAttributes((Enumeration) null);   
      }
    catch (NullPointerException ex)
      {
        pass = true;
      }
View Full Code Here

   */
  public void test(TestHarness harness)     
  {
    harness.checkPoint("getAttributeNames()");
     
    SimpleAttributeSet s = new SimpleAttributeSet();
    Enumeration e = s.getAttributeNames();
    harness.check(e.hasMoreElements(), false);

    s.addAttribute("X1", "Y1");
    e = s.getAttributeNames();
    harness.check(e.hasMoreElements(), true);
    harness.check(e.nextElement(), "X1");
    harness.check(e.hasMoreElements(), false);
     
    // add an attribute that exists in the resolve parent, same value
    SimpleAttributeSet sParent = new SimpleAttributeSet();
    s.setResolveParent(sParent);
    s.removeAttribute("X1");
    e = s.getAttributeNames();
    harness.check(e.hasMoreElements(), true);
    harness.check(e.nextElement(), AttributeSet.ResolveAttribute);
View Full Code Here

   *
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)     
  {
    SimpleAttributeSet s = new SimpleAttributeSet();
   
    // check default
    harness.check(StyleConstants.getBackground(s), Color.black);
   
    // check local setting
    StyleConstants.setBackground(s, Color.red);
    harness.check(StyleConstants.getBackground(s), Color.red);
   
    // check resolving parent setting
    s.removeAttribute(StyleConstants.Background);
    SimpleAttributeSet parent = new SimpleAttributeSet();
    s.setResolveParent(parent);
    StyleConstants.setBackground(parent, Color.yellow);
    harness.check(StyleConstants.getBackground(s), Color.yellow);  
   
    // try null argument
View Full Code Here

   *
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)     
  {
    SimpleAttributeSet s = new SimpleAttributeSet();
   
    // check default
    harness.check(StyleConstants.getRightIndent(s), 0.0f);
   
    // check local setting
    StyleConstants.setRightIndent(s, 1.0f);
    harness.check(StyleConstants.getRightIndent(s), 1.0f);
   
    // check resolving parent setting
    s.removeAttribute(StyleConstants.RightIndent);
    SimpleAttributeSet parent = new SimpleAttributeSet();
    s.setResolveParent(parent);
    StyleConstants.setRightIndent(parent, 2.0f);
    harness.check(StyleConstants.getRightIndent(s), 2.0f);   
   
    // try null argument
View Full Code Here

TOP

Related Classes of javax.swing.text.SimpleAttributeSet

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.