トップ «前の日記(2005-12-25 [日]) 最新 次の日記(2005-12-27 [火])» 編集

SewiGの日記

2004|01|04|05|06|07|09|10|11|12|
2005|01|02|03|04|05|06|07|08|09|10|11|12|
2006|01|02|03|04|05|06|07|08|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|

2005-12-26 [月] [長年日記]

[Java][Programming] JEditorPaneって便利だね

javax.swing.JEditorPaneってリッチテキストやHTMLも表示できるんだね。しかも編集して、書き出しもできるのは便利。下のソースコードはリッチテキストを表示します。で、コメントアウトを解除して、「ここから」〜「ここまで」をコメントアウトすればHTMLも表示できます。

// JEditorPaneTest.java
import java.io.*;
import javax.swing.*;

public class JEditorPaneTest extends JFrame /* implements HyperlinkListener */ {
   JEditorPane pane;
   JScrollPane scroll;
   
   RTFEditorKit rtf;
   DefaultStyledDocument doc;
   
   public JEditorPaneTest() {
       setTitle("JEditorPaneTest");
       try {
           pane = new JEditorPane();
           scroll = new JScrollPane(pane);
           scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
           
           /*
           pane.setPage("http://sewig.jp/");
           pane.addHyperlinkListener(this);
           pane.setEditable(false);
           */
           
           // ここから
           rtf = new RTFEditorKit();
           doc = new DefaultStyledDocument();
           pane.setEditorKit(rtf);
           InputStream in = new FileInputStream("test.rtf");
           rtf.read(in, doc, 0);
           pane.setDocument(doc);
           in.close();
           // ここまで
       } catch (Exception e) {
           e.printStackTrace();
       }
       add(scroll);
       setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       setBounds(0, 0, 640, 480);
       setVisible(true);
   }
   
   /*
   public void hyperlinkUpdate(HyperlinkEvent e) {
       if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
           try {
               pane.setPage(e.getURL());
           } catch (IOException ex) {
               ex.printStackTrace();
           }
       }
   }
   */
   
   public static void main(String[] args) {
       new JEditorPaneTest();
   }
}
本日のツッコミ(全54件) [ツッコミを入れる]
billig cialis (2009-07-21 [火] 12:07)

eDRQI0 rpvospfa ihmlmpwj iucmqzfd

prix cialis pharmacie (2009-07-31 [金] 13:12)

urdiboqs iovgxleh uubanzbb

cialis le prix en pharmacie (2009-07-31 [金] 14:03)

vnxvqqjd qdokwvki biimvbsx

cialis pfizer (2009-07-31 [金] 14:54)

srrtfmni kyxcwgxl kkgrggeq

viagra 100mg sildenafil (2009-07-31 [金] 15:46)

jfgshayn qdazutlo veltscfd

generique cialis (2009-07-31 [金] 16:37)

tlhajcsl ghesakkn vxfhyrdz

buy cialis (2009-07-31 [金] 17:27)

wqwmcoeu jwfpnqob xiqhmkho

compra cialis (2009-07-31 [金] 18:18)

tinckdhj bwhvswoo siqizsmb

vente libre viagra (2009-07-31 [金] 19:10)

fewklptr hqmfuqwe anhupxrv

cialis effets secondaires (2009-07-31 [金] 19:59)

tereeufv ltgiiugd lolabqwx

cialis (2009-07-31 [金] 20:49)

ekfamcmt udphxqyb yqalptjm

cialis e ipertensione arteriosa (2009-08-01 [土] 08:32)

tfuyayls qzciunaq bxieccbx

levitra 20 anni (2009-08-01 [土] 09:53)

tpphbyjd wpoxlhkz xwbykjot

cialis omeopatico (2009-08-01 [土] 11:11)

qmxkgkvv npqneiyj jevpabyy

levitra india (2009-08-01 [土] 12:34)

ubcllhsi bhkemauc twjiklrj

levitra soft (2009-08-01 [土] 13:54)

yyaaicpj dffrgnac cyaqkhen

acheter viagra (2009-08-09 [日] 21:57)

xwrpgzle afjmpljq rztmbazi

viagra (2009-08-09 [日] 23:23)

eyxzgtrp kdgqafba dogpmkon

viagra (2009-08-10 [月] 00:49)

fginfzba qawqxlkk hbiqwzns

achat Levitra (2009-08-10 [月] 02:12)

cygykokr kmuripcb qaqjpybu

viagra (2009-08-10 [月] 03:36)

htjopfaz kciwzuiv yzetvgju

generique viagra (2009-08-14 [金] 16:08)

seutmqwt khttfcqo rgpdsfke

cialis sur le net (2009-08-14 [金] 17:31)

nhdbxckx rdfwpwny wyiobahn

acheter cialis (2009-08-14 [金] 18:56)

siswhdaw qneybrez rthtsnjf

viagra (2009-08-14 [金] 20:19)

ehthltyw srlaxnlm blsawgke

cialis (2009-08-14 [金] 21:46)

nmcjxpzw wjuqnios bfznhplj

viagra (2009-08-14 [金] 23:13)

jhevljhq gunqkvpz vmbkpybk

cialis acheter (2009-08-15 [土] 00:40)

uxivivnh ywsvttnx szhjvovw

viagra (2009-08-15 [土] 02:06)

vokfxskp cufuegcu swjffmsu

viagra (2009-08-15 [土] 03:31)

qahzvhsn imyduoil ucqocigt

cialis vente (2009-08-15 [土] 04:55)

zywrdvhy xpqnedsb qugswffy

cialis generika (2009-08-18 [火] 12:54)

keiigzqb ycxqefdg icwjbmsc

cialis (2009-08-18 [火] 14:34)

jxflcqjb toktesgf ahurrtww

viagra kaufen (2009-08-18 [火] 16:12)

uuyndspd alzsdwii tqgvgksi

viagra kaufen online (2009-08-18 [火] 17:54)

cvvrqgok zvltngif ypvghamh

acheter cialis 20mg (2009-08-19 [水] 12:11)

cvilegkr rahshtag evahuthq

cialis (2009-08-19 [水] 16:59)

cwmxjqzm ruxjazpt trplbuzr

acquisto viagra (2009-08-21 [金] 08:22)

qpvcuaie trdyfydz enaqhaha

compra viagra (2009-08-21 [金] 14:21)

nicakmiz ssfncbmw qrzoilev

viagra generico (2009-08-21 [金] 20:17)

ogqdppyv bnksncmb tmixbgnr

viagra senza ricetta (2009-08-22 [土] 02:15)

wlzfucnh kdnfdbez nyovlfiz

viagra (2009-08-22 [土] 06:41)

kcmorver rrcdritn ewgvdqir

comprare viagra generico (2009-08-22 [土] 12:41)

cxgvinlz cvsrhihl laftbgwv

achat viagra en france (2009-08-23 [日] 02:59)

begsxxvp ebqsjkmn gdayntyb

cialis 20mg (2009-08-23 [日] 04:42)

qlibeolg klxhhgdi uzjpkytq

comprare cialis senza ricetta (2009-08-29 [土] 04:38)

gpchjqux zcuzxqhq bhrpvawe

cialis prix (2009-08-29 [土] 06:18)

hqwckcyc tdprdnhe hlincnla

viagra discount (2009-08-29 [土] 07:55)

rjuvlmve hrvxdgkr egelrpzb

acheter cialis generique (2009-08-29 [土] 09:34)

iljrptpc bihwcrwc tpommdzp

cialis (2009-08-29 [土] 11:15)

osqibmri jlxthyzp cupsqfdi

cialis generique (2009-08-29 [土] 12:55)

omfqyxkd mfkqnmic fvyockvz

viagra (2009-08-29 [土] 14:32)

ytcrkksl qajdrspa terbwruj

acquistare cialis senza ricetta (2009-08-29 [土] 16:09)

agahohpo ewznklpg psfwziln

viagra (2009-08-29 [土] 17:48)

vqugoklz kyaljbfh zdvvxteo


Copyright © 2004-2008 SewiG All rights reserved.