Swing/StyleSheet のバックアップソース(No.4)
- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- バックアップ を表示
- Swing/StyleSheet へ行く。
- 1 (2009-07-21 (火) 00:51:27)
- 2 (2009-10-19 (月) 14:42:54)
- 3 (2011-04-14 (木) 10:49:52)
- 4 (2012-05-28 (月) 17:48:46)
- 5 (2013-01-08 (火) 18:40:28)
- 6 (2013-09-05 (木) 23:59:06)
- 7 (2014-11-25 (火) 03:03:31)
- 8 (2015-10-28 (水) 21:00:08)
- 9 (2017-04-14 (金) 19:03:07)
- 10 (2018-04-06 (金) 14:37:37)
- 11 (2019-04-19 (金) 13:43:27)
- 12 (2020-04-03 (金) 17:30:06)
- 13 (2021-10-08 (金) 17:38:46)
TITLE:JEditorPaneのHTMLEditorKitにCSSを適用 #navi(../) RIGHT:Posted by &author(aterai); at 2009-07-20 *JEditorPaneのHTMLEditorKitにCSSを適用 [#y336d1e1] JEditorPaneにStyleSheetを追加したHTMLEditorKitを設定します。 -&jnlp; -&jar; -&zip; //#screenshot #ref(http://lh5.ggpht.com/_9Z4BYR88imo/TQTT6cwbhCI/AAAAAAAAAlM/PsSYnlumJJg/s800/StyleSheet.png) **サンプルコード [#p2576f29] #code{{ StyleSheet styleSheet = new StyleSheet(); styleSheet.addRule("body {font-size: 12pt;}"); styleSheet.addRule(".highlight {color: red; background: green}"); HTMLEditorKit htmlEditorKit = new HTMLEditorKit(); htmlEditorKit.setStyleSheet(styleSheet); JEditorPane editor = new JEditorPane(); editor.setEditorKit(htmlEditorKit); editor.setText(makeTestHtml()); }} **解説 [#f80e2a15] 上記のサンプルでは、クラス名が.highlightの要素の文字色と背景色をCSSで変更しています。 **参考リンク [#kc26b056] -[http://www.ne.jp/asahi/hishidama/home/tech/java/swing/JEditorPane.html Java Swing「JEditorPane」メモ(Hishidama's Swing-JEditorPane Memo)] -[http://forums.sun.com/thread.jspa?threadID=580677 Swing - HTMLEditorKit and CSS] -[http://docs.oracle.com/javase/jp/6/api/javax/swing/text/html/StyleSheet.html StyleSheet (Java Platform SE 6)] -- [http://docs.oracle.com/javase/jp/6/api/javax/swing/text/html/CSS.html 対応しているCSSプロパティ一覧 - CSS (Java Platform SE 6)] -[http://www.devdaily.com/blog/post/jfc-swing/how-add-style-stylesheet-jeditorpane-example-code/ How to add stylesheet information to a JEditorPane (jfc/swing)] -[[GraphicsEnvironmentにFontを登録して使用する>Swing/RegisterFont]] **コメント [#y67a16b3] #comment