Mega Code Archive

 
Categories / Java Tutorial / Swing
 

Create a tab set from the tab stops

import java.util.ArrayList; import java.util.List; import javax.swing.JTextPane; import javax.swing.text.Style; import javax.swing.text.StyleConstants; import javax.swing.text.TabSet; import javax.swing.text.TabStop; public class Main {   public static void main(String[] argv) {       JTextPane textPane = new JTextPane();     List list = new ArrayList();     TabStop[] tstops = (TabStop[]) list.toArray(new TabStop[0]);     TabSet tabs = new TabSet(tstops);     Style style = textPane.getLogicalStyle();     StyleConstants.setTabSet(style, tabs);     textPane.setLogicalStyle(style);   } }