There are 1 code examples for javax.swing.text.TabSet.

The API names are highlighted below. You can use suckoo button to vote the code example(s) you like. The best code example will be ranked first next time. Thanks a lot for your feedback.

Project Name: weka Package: weka.gui.scripting

Source Code: SyntaxDocument.java (Click to view .java file)

Method Code:
vote
like

/** 
 * sets the number of characters per tab.
 * @param charactersPerTabthe characters per tab
 */
public void setTabs(int charactersPerTab){
  Font f=new Font(m_FontName,Font.PLAIN,m_FontSize);
  FontMetrics fm=Toolkit.getDefaultToolkit().getFontMetrics(f);
  int charWidth=fm.charWidth('w');
  int tabWidth=charWidth * charactersPerTab;
  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);
}