Package javax.swing.text

Examples of javax.swing.text.TabStop


    TabStop[] tabs = new TabStop[50];

    for(int j = 0; j < tabs.length; j++) {
      int tab = j + 1;
      tabs[j] = new TabStop(tab * tabWidth);
    }

    TabSet tabSet = new TabSet(tabs);
    SimpleAttributeSet attributes = new SimpleAttributeSet();
    StyleConstants.setTabSet(attributes, tabSet);
View Full Code Here


        TabStop[] tabs = new TabStop[50];
        float width = fontMetrics.stringWidth(" ");

        int tabSize = GUISaveState.getInstance().getTabSize();
        for (int i = 0; i < tabs.length; i++) {
            tabs[i] = new TabStop(width * (tabSize + tabSize * i));
        }
        TAB_SET = new TabSet(tabs);
        StyleConstants.setTabSet(commentAttributes, TAB_SET);
        StyleConstants.setTabSet(javadocAttributes, TAB_SET);

View Full Code Here

public class constructor implements Testlet
{
  public void test(TestHarness harness)
  {
    TabStop ts1 = new TabStop(1.0f);
    TabStop ts2 = new TabStop(2.0f);
    TabStop ts3 = new TabStop(3.0f);
    TabStop[] tabs = new TabStop[] {ts1, ts2, ts3};
    TabSet s = new TabSet(tabs);
    harness.check(s.getTabCount(), 3);
    harness.check(s.getTab(0), ts1);
    harness.check(s.getTab(1), ts2);
    harness.check(s.getTab(2), ts3);
   
    // try modifying the original tab array
    TabStop ts4 = new TabStop(4.0f);
    tabs[1] = ts4;
    harness.check(s.getTab(1), ts2);
   
    // what if the original array is not ordered?
    TabStop[] tabs2 = new TabStop[] {ts1, ts3, ts2};
View Full Code Here

public class getTabIndexAfter implements Testlet
{
  public void test(TestHarness harness)
  {
    TabStop ts1 = new TabStop(1.0f);
    TabStop ts2 = new TabStop(2.0f);
    TabStop ts3 = new TabStop(3.0f);
    TabStop[] tabs = new TabStop[] {ts1, ts2, ts3};
    TabSet s = new TabSet(tabs);
    harness.check(s.getTabIndexAfter(-1.0f), 0);
    harness.check(s.getTabIndexAfter(0.0f), 0);
    harness.check(s.getTabIndexAfter(0.5f), 0);
View Full Code Here

public class getTabIndex implements Testlet
{
  public void test(TestHarness harness)
  {
    TabStop ts1 = new TabStop(1.0f);
    TabStop ts2 = new TabStop(2.0f);
    TabStop ts3 = new TabStop(3.0f);
    TabStop[] tabs = new TabStop[] {ts1, ts2, ts3};
    TabSet s = new TabSet(tabs);
    harness.check(s.getTabIndex(ts1), 0);
    harness.check(s.getTabIndex(ts2), 1);
    harness.check(s.getTabIndex(ts3), 2);
   
    harness.check(s.getTabIndex(new TabStop(2.0f)), -1);
   
    harness.check(s.getTabIndex(null), -1);
  }
View Full Code Here

   
    // check default
    harness.check(StyleConstants.getTabSet(s), null);
   
    // check local setting
    TabStop[] tabs1 = new TabStop[] {new TabStop(8.0f)};
    TabSet ts1 = new TabSet(tabs1);
    StyleConstants.setTabSet(s, ts1);
    harness.check(StyleConstants.getTabSet(s), ts1);
   
    // check resolving parent setting
    s.removeAttribute(StyleConstants.TabSet);
    SimpleAttributeSet parent = new SimpleAttributeSet();
    s.setResolveParent(parent);
    TabStop[] tabs2 = new TabStop[] {new TabStop(10.0f)};
    TabSet ts2 = new TabSet(tabs2);
    StyleConstants.setTabSet(parent, ts2);
    harness.check(StyleConstants.getTabSet(s), ts2);   
   
    // try null argument
View Full Code Here

  public void test(TestHarness harness)     
  {
    SimpleAttributeSet s = new SimpleAttributeSet();
   
    // check local setting
    TabStop[] tabs1 = new TabStop[] {new TabStop(8.0f)};
    TabSet ts1 = new TabSet(tabs1);
    StyleConstants.setTabSet(s, ts1);
    harness.check(StyleConstants.getTabSet(s), ts1);
   
    // try null value
View Full Code Here

public class toString implements Testlet
{
  public void test(TestHarness harness)
  {
    TabStop ts1 = new TabStop(1.0f);
    harness.check(ts1.toString(), "tab @1.0");
    ts1 = new TabStop(2.0f, TabStop.ALIGN_RIGHT, TabStop.LEAD_EQUALS);
    harness.check(ts1.toString(), "right tab @2.0 (w/leaders)");
    ts1 = new TabStop(10.999f, TabStop.ALIGN_CENTER, TabStop.LEAD_HYPHENS);
    harness.check(ts1.toString(), "center tab @10.999 (w/leaders)");
    ts1 = new TabStop(3.3f, TabStop.ALIGN_BAR, TabStop.LEAD_NONE);
    harness.check(ts1.toString(), "bar tab @3.3");
    ts1 = new TabStop(3.3f, TabStop.ALIGN_DECIMAL, TabStop.LEAD_UNDERLINE);
    harness.check(ts1.toString(), "decimal tab @3.3 (w/leaders)");
    ts1 = new TabStop(3.3f, 99, 666);
    harness.check(ts1.toString(), "tab @3.3 (w/leaders)");
  }
View Full Code Here

  }
 
  public void testConstructor1(TestHarness harness)
  {
    harness.checkPoint("(float)");
    TabStop ts1 = new TabStop(1.0f);
    harness.check(ts1.getPosition(), 1.0f);
    harness.check(ts1.getAlignment(), TabStop.ALIGN_LEFT);
    harness.check(ts1.getLeader(), TabStop.LEAD_NONE);
   
    // try negative
    ts1 = new TabStop(-1.0f);
    harness.check(ts1.getPosition(), -1.0f);
  }
View Full Code Here

  }

  public void testConstructor2(TestHarness harness)
  {
    harness.checkPoint("(float, int, int)");
    TabStop ts1 = new TabStop(1.0f, TabStop.ALIGN_DECIMAL, TabStop.LEAD_DOTS);
    harness.check(ts1.getPosition(), 1.0f);
    harness.check(ts1.getAlignment(), TabStop.ALIGN_DECIMAL);
    harness.check(ts1.getLeader(), TabStop.LEAD_DOTS);
   
    // try bad alignment
    ts1 = new TabStop(1.0f, 99, TabStop.LEAD_DOTS);
    harness.check(ts1.getPosition(), 1.0f);
    harness.check(ts1.getAlignment(), 99);
    harness.check(ts1.getLeader(), TabStop.LEAD_DOTS);

    // try bad lead
    ts1 = new TabStop(1.0f, TabStop.ALIGN_DECIMAL, 99);
    harness.check(ts1.getPosition(), 1.0f);
    harness.check(ts1.getAlignment(), TabStop.ALIGN_DECIMAL);
    harness.check(ts1.getLeader(), 99);
  }
View Full Code Here

TOP

Related Classes of javax.swing.text.TabStop

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.