Java JTabbedPane getLineTabs(StyledDocument doc, int startOffset)

Here you can find the source of getLineTabs(StyledDocument doc, int startOffset)

Description

get Line Tabs

License

Apache License

Declaration

public static String getLineTabs(StyledDocument doc, int startOffset) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import javax.swing.text.BadLocationException;
import javax.swing.text.StyledDocument;

public class Main {
    public static String getLineTabs(StyledDocument doc, int startOffset) {
        int i = startOffset;
        String s;//  ww w.  j  a  v a  2  s  . co  m
        try {
            do {

                s = doc.getText(i, 1);
                if ((i > 0 && !"\n".equals(s))) {//NOI18N
                    i--;
                } else {
                    break;
                }

            } while (true);
            StringBuilder tabs = new StringBuilder();
            i++;
            do {
                s = doc.getText(i, 1);
                if (" ".equals(s) || "\t".equals(s)) {//NOI18N
                    tabs.append(s);
                } else if (Character.isJavaIdentifierPart(s.charAt(0))) {
                    break;
                }
                i++;

            } while (i < doc.getLength());
            return tabs.toString();
        } catch (BadLocationException ex) {
            throw new RuntimeException(ex);//should never happen
        }
    }
}

Related

  1. createTabbedPane()
  2. findParentJTabbedPane(JComponent c)
  3. getConfigPanelFromTabbedPane(JTabbedPane mainTabbedPane)
  4. getIndexOf(JTabbedPane tabbedPane, Component component)
  5. getJTabbedPaneAncestor(Component c)
  6. getNextSubTabIndex(JTabbedPane tabs, int tabIndex)
  7. getOffsetOfVirtualColumn(Segment seg, int tabSize, int column, int[] totalVirtualWidth)
  8. getParagraphStyle(SimpleAttributeSet attrSet, int align, float firstLineIndent, float leftIndent, float rightIndent, float lineSpace, float spaceAbove, float spaceBelow, TabSet tabs)
  9. getTabbedPaneComponentIndex(JTabbedPane tabbedPane, String title)