Swing/TabSize のバックアップ差分(No.16)
- バックアップ一覧
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- バックアップ を表示
- Swing/TabSize へ行く。
- 1 (2005-04-25 (月) 00:01:26)
- 2 (2005-04-28 (木) 04:33:02)
- 3 (2005-10-14 (金) 17:33:26)
- 4 (2005-12-14 (水) 16:23:18)
- 5 (2006-02-27 (月) 16:47:45)
- 6 (2006-05-02 (火) 16:07:48)
- 7 (2007-03-03 (土) 03:54:51)
- 8 (2007-09-26 (水) 13:51:43)
- 9 (2010-03-08 (月) 12:21:45)
- 10 (2010-03-08 (月) 13:41:20)
- 11 (2013-03-30 (土) 21:06:31)
- 12 (2013-05-24 (金) 17:27:23)
- 13 (2013-09-06 (金) 15:30:46)
- 14 (2014-11-25 (火) 02:38:25)
- 15 (2014-11-25 (火) 03:03:31)
- 16 (2016-01-01 (金) 01:09:03)
- 17 (2016-01-01 (金) 16:25:14)
- 18 (2017-06-17 (土) 22:04:10)
- 19 (2018-06-21 (木) 17:52:48)
- 20 (2018-10-05 (金) 01:11:30)
- 21 (2020-10-02 (金) 10:16:25)
- 22 (2022-06-17 (金) 11:58:07)
- 23 (2023-04-10 (月) 00:10:17)
- 追加された行はこの色です。
- 削除された行はこの色です。
--- title: JTextPaneでタブサイズを設定 tags: [JTextPane, StyledDocument, SimpleAttributeSet] author: aterai pubdate: 2005-04-25T00:01:26+09:00 description: JTextPaneのStyledDocumentが使用するパラグラフ属性として、タブストップが展開する文字数を設定します。 --- * 概要 [#bc0a9823] `JTextPane`の`StyledDocument`が使用するパラグラフ属性として、タブストップが展開する文字数を設定します。[https://forums.oracle.com/thread/1507037 Swing (Archive) - tabsize in JTextPane]からの引用です。 `JTextPane`の`StyledDocument`が使用するパラグラフ属性として、タブストップが展開する文字数を設定します。[https://community.oracle.com/thread/1507037 Swing (Archive) - tabsize in JTextPane]からの引用です。 #download(https://lh5.googleusercontent.com/_9Z4BYR88imo/TQTUxfmvVtI/AAAAAAAAAmk/hIXOEpGYKYw/s800/TabSize.png) * サンプルコード [#f20b0404] #code(link){{ textpane.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); FontMetrics fm = textpane.getFontMetrics(textpane.getFont()); int charWidth = fm.charWidth('m'); int tabLength = charWidth * 4; TabStop[] tabs = new TabStop[10]; for (int j = 0; j < tabs.length; j++) { tabs[j] = new TabStop((j + 1) * tabLength); } TabSet tabSet = new TabSet(tabs); SimpleAttributeSet attrs = new SimpleAttributeSet(); StyleConstants.setTabSet(attrs, tabSet); int l = textpane.getDocument().getLength(); textpane.getStyledDocument().setParagraphAttributes(0, l, attrs, false); }} * 解説 [#w2ad23ff] `JTextArea`は`setTabSize`メソッドでタブサイズを指定することができますが、`JTextPane`では、上記のサンプルのような方法でタブサイズを指定します。 * 参考リンク [#ha0226f7] - [https://forums.oracle.com/thread/1507037 Swing (Archive) - tabsize in JTextPane] - [https://community.oracle.com/thread/1507037 Swing (Archive) - tabsize in JTextPane] * コメント [#h20d6278] #comment #comment