Swing/NoWrapTextPane のバックアップソース(No.5)
- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- バックアップ を表示
- Swing/NoWrapTextPane へ行く。
- 1 (2007-09-24 (月) 18:04:06)
- 2 (2007-09-25 (火) 12:23:27)
- 3 (2007-09-25 (火) 16:22:50)
- 4 (2007-09-25 (火) 19:14:19)
- 5 (2012-08-02 (木) 21:04:03)
- 6 (2013-01-31 (木) 22:56:49)
- 7 (2013-05-06 (月) 15:18:45)
- 8 (2013-05-07 (火) 03:20:53)
- 9 (2013-07-24 (水) 21:52:19)
- 10 (2013-07-26 (金) 01:43:55)
- 11 (2013-07-27 (土) 01:01:34)
- 12 (2013-09-06 (金) 15:34:39)
- 13 (2014-11-01 (土) 00:46:09)
- 14 (2014-11-25 (火) 03:03:31)
- 15 (2015-10-29 (木) 16:24:34)
- 16 (2017-03-28 (火) 15:24:43)
- 17 (2017-11-02 (木) 15:34:40)
- 18 (2018-02-01 (木) 19:38:14)
- 19 (2020-01-28 (火) 16:33:24)
- 20 (2021-07-22 (木) 22:11:40)
- 21 (2022-08-20 (土) 22:15:25)
TITLE:JEditorPaneで長い行を折り返さない #navi(../) RIGHT:Posted by &author(aterai); at 2007-09-24 *JEditorPaneで長い行を折り返さない [#v31d450a] JEditorPaneや、JTextPaneで、行をViewPortの幅で折り返さないよう設定します。[http://forums.sun.com/thread.jspa?threadID=622683 Swing - Disabling word wrap for JTextPane]の投稿をそのまま引用しています。 -&jnlp; -&jar; -&zip; //#screenshot #ref(http://lh6.ggpht.com/_9Z4BYR88imo/TQTQbo-LQJI/AAAAAAAAAfk/YnnnPAQE-R4/s800/NoWrapTextPane.png) **サンプルコード [#qd3a5388] #code(link){{ class NoWrapParagraphView extends ParagraphView { public NoWrapParagraphView(Element elem) { super(elem); } protected SizeRequirements calculateMinorAxisRequirements( int axis, SizeRequirements r) { SizeRequirements req = super.calculateMinorAxisRequirements(axis, r); req.minimum = req.preferred; return req; } public int getFlowSpan(int index) { return Integer.MAX_VALUE; } } }} **解説 [#k626f953] 上記のサンプルでは、スパンの必要サイズを計算するcalculateMinorAxisRequirementsメソッドなどをオーバーライドして、行折り返し段落のビュー(ParagraphView)で折り返しが発生しないようにしています。 JEditorPaneやJTextPaneといったStyledDocumentをモデルにしているテキストコンポーネントに非常に長い行をペーストした場合、表示が更新されなくなりますが、折り返しできなくしてしまうと多少ましになるようです。 JTextAreaでも行を非常に長くしてしまうと、カーソルキーの移動などで異常に時間がかかる場合があります。 - 例えば、このサンプルで、カーソルを一番最後に移動し、一行目(非常に長い行)にUp↑キーで移動すると発生する - [http://forums.sun.com/thread.jspa?threadID=5217158 Swing - Long last line in wrappable textarea hangs GUI (bug in java?)] **参考リンク [#ydbfb81a] - [http://forums.sun.com/thread.jspa?threadID=622683 Swing - Disabling word wrap for JTextPane] - [http://www.java2s.com/Code/Java/Swing-JFC/NonWrappingWrapTextPane.htm Non Wrapping(Wrap) TextPane : TextField : Swing JFC : Java examples (example source code) Organized by topic] -[http://bugs.sun.com/view_bug.do?bug_id=6502558 Bug ID: 6502558 AbstractDocument fires event not on Event Dispatch Thread] --[http://weblogs.java.net/blog/alexfromsun/archive/2006/02/debugging_swing.html Alexander Potochkin's Blog: Debugging Swing, the final summary] **コメント [#rdd302ba] #comment