Package javax.swing.text

Examples of javax.swing.text.TabSet


  {
    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};
    TabSet s2 = new TabSet(tabs2);
    harness.check(s2.getTabCount(), 3);
    harness.check(s2.getTab(0), ts1);
    harness.check(s2.getTab(1), ts3);
    harness.check(s2.getTab(2), ts2);
   
    // try null
    s2 = new TabSet(null);
    harness.check(s2.getTabCount(), 0);
  }
View Full Code Here


        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);
        int length = this.getDocument().getLength();
        this.getStyledDocument().setParagraphAttributes(0, length, attributes, false);
    }
View Full Code Here

      tabs[j] = new TabStop((j + 1) * tabWidth);
    }

    SimpleAttributeSet attributes = new SimpleAttributeSet();

    StyleConstants.setTabSet(attributes, new TabSet(tabs));

    getDocument().removeUndoableEditListener(undoManager); // Avoid this change to be undone
    getStyledDocument().setParagraphAttributes(0, getDocument().getLength(), attributes, false);
    getDocument().addUndoableEditListener(undoManager);
  }
View Full Code Here

    {
      int tab = j + 1;
      tabs[j] = new TabStop( tab * tabWidth );
    }
    TabSet tabSet = new TabSet(tabs);
    SimpleAttributeSet attributes = new SimpleAttributeSet();
    StyleConstants.setTabSet(attributes, tabSet);
    int length = textPane.getDocument().getLength();
    textPane.getStyledDocument().setParagraphAttributes(0, length, attributes, false);
  }
View Full Code Here

    TabStop[] tabs = new TabStop[MAX_TABS];

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

    TabSet tabSet = new TabSet(tabs);
    SimpleAttributeSet attributes = new SimpleAttributeSet();
    StyleConstants.setTabSet(attributes, tabSet);
    int length = getLength();
    setParagraphAttributes(0, length, attributes, false);
  }
View Full Code Here

  protected void setTabs( Document doc, int rangeStart, int len )
  {
    if( doc instanceof StyledDocument ) {
      final StyledDocument sdoc = (StyledDocument) doc;
      final SimpleAttributeSet attrs = new SimpleAttributeSet();
      StyleConstants.setTabSet( attrs, new TabSet( tabs ));
      if( rangeStart == -1 ) {
        rangeStart  = 0;
        len      = sdoc.getLength();
      }
      sdoc.setParagraphAttributes( rangeStart, len, attrs, false );
View Full Code Here

        SimpleAttributeSet attributes = createTabAttributes(charactersPerTab);
        applyTabAttributes(attributes);
    }

    private SimpleAttributeSet createTabAttributes(int charactersPerTab) {
        TabSet tabSet = createTabSet(charactersPerTab);
        SimpleAttributeSet attributes = new SimpleAttributeSet();
        StyleConstants.setTabSet(attributes, tabSet);
        return attributes;
    }
View Full Code Here

        return attributes;
    }

    private TabSet createTabSet(int charactersPerTab) {
        TabStop[] tabs = createTabStops(charactersPerTab);
        return new TabSet(tabs);
    }
View Full Code Here

      do_reapplyAll();
      BufferedImage im = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB); // this is used to derive the tab width
      int gap = tabSize * im.createGraphics().getFontMetrics(new Font(fontName, Font.PLAIN, fontSize)).charWidth('X');
      TabStop[] pos = new TabStop[100];
      for(int i=0; i<100; i++) { pos[i] = new TabStop(i*gap + gap); }
      StyleConstants.setTabSet(tabset, new TabSet(pos));
      setParagraphAttributes(0, getLength(), tabset, false);
   }
View Full Code Here

TOP

Related Classes of javax.swing.text.TabSet

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.