⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e993. customizing tab stops in a jtextpane component.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
This example demonstrates the four types of tabs that can be used in a JTextPane. In a left-aligned tab, characters appear after the tab. In a right-aligned tab, characters appear in front of the tab. In a center-aligned tab, characters appear centered around the tab. In a decimal-aligned tab, the decimal point is anchored at the tab. 
    // Create a text pane
    JTextPane textPane = new JTextPane();
    
    // Create one of each type of tab stop
    java.util.List list = new ArrayList();
    
    // Create a left-aligned tab stop at 100 pixels from the left margin
    float pos = 100;
    int align = TabStop.ALIGN_LEFT;
    int leader = TabStop.LEAD_NONE;
    TabStop tstop = new TabStop(pos, align, leader);
    list.add(tstop);
    
    // Create a right-aligned tab stop at 200 pixels from the left margin
    pos = 200;
    align = TabStop.ALIGN_RIGHT;
    leader = TabStop.LEAD_NONE;
    tstop = new TabStop(pos, align, leader);
    list.add(tstop);
    
    // Create a center-aligned tab stop at 300 pixels from the left margin
    pos = 300;
    align = TabStop.ALIGN_CENTER;
    leader = TabStop.LEAD_NONE;
    tstop = new TabStop(pos, align, leader);
    list.add(tstop);
    
    // Create a decimal-aligned tab stop at 400 pixels from the left margin
    pos = 400;
    align = TabStop.ALIGN_DECIMAL;
    leader = TabStop.LEAD_NONE;
    tstop = new TabStop(pos, align, leader);
    list.add(tstop);
    
    // Create a tab set from the tab stops
    TabStop[] tstops = (TabStop[])list.toArray(new TabStop[0]);
    TabSet tabs = new TabSet(tstops);
    
    // Add the tab set to the logical style;
    // the logical style is inherited by all paragraphs
    Style style = textPane.getLogicalStyle();
    StyleConstants.setTabSet(style, tabs);
    textPane.setLogicalStyle(style);

 Related Examples 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -