首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JTextPane缩进

JTextPane缩进
EN

Stack Overflow用户
提问于 2011-08-14 01:14:05
回答 1查看 3.2K关注 0票数 3

有没有一种在JTextPane中缩进文本块的方法

代码语言:javascript
复制
import javax.swing.*;
import java.awt.*;
import javax.swing.text.StyledDocument;

public class SimpleTextPane {

    public static void main(String... args){
        JFrame frame = new JFrame();
        JTextPane textPane = new JTextPane();
        textPane.setPreferredSize(new Dimension(400, 400));
        StyledDocument doc = textPane.getStyledDocument();
        try {
            doc.insertString(doc.getLength(), "Now he has departed from this strange world a little ahead of me. That means nothing. People like us, who believe in physics, know that the distinction between past, present, and future is only a stubbornly persistent illusion", doc.getStyle(""));
            doc.insertString(doc.getLength(), "\n\n" + "I WOULD LIKE TO BE INDENTED Yes, we have to divide up our time like that, between our politics and our equations. But to me our equations are far more important, for politics are only a matter of present concern. A mathematical equation stands forever.", doc.getStyle(""));
        } catch (Exception e) {
        }
        frame.getContentPane().add(new JScrollPane(textPane));
        frame.setLocationRelativeTo(null);
        frame.pack();
        frame.setVisible(true);
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-08-14 01:24:59

编辑:

使用setLeftIndent()

检查this examplethis one

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7052061

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档