그 예는 JEditorPane의 연장 이유를 확실하지 :
아래 내가 참조로 사용하고있는 코드의 링크입니다. 편집기 창은 HTML 용입니다. 스타일이 지정된 텍스트에 JTextPane을 사용하는 것을 선호합니다. 또한 사용자 정의 편집기 키트가 사용되는 이유를 모릅니다.
이
import javax.swing.*;
import javax.swing.text.*;
import java.awt.*;
//public class HangingIndent extends JEditorPane {
public class HangingIndent extends JTextPane {
public static void main(String[] args) {
JFrame frame = new JFrame("Negative (Hanging) first line indent");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final HangingIndent app = new HangingIndent();
// app.setEditorKit(new MyEditorKit());
app.setText("The paragraph with long text is necessary to show how " +
"hanging indent can be achieved. We should set not only the " +
"first line indent but the same left indent.");
StyledDocument doc=(StyledDocument)app.getDocument();
SimpleAttributeSet attrs=new SimpleAttributeSet();
StyleConstants.setFirstLineIndent(attrs, -50);
StyleConstants.setLeftIndent(attrs, 50);
doc.setParagraphAttributes(0,doc.getLength(),attrs, false);
JScrollPane scroll = new JScrollPane(app);
frame.getContentPane().add(scroll);
frame.setSize(400, 200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
public HangingIndent() {
super();
}
}
당신이 http://stackoverflow.com/questions/12817239/jtextpane-and-hanging-indent-glitch – Ups