SewiGの日記
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();
}
}
2006-12-26 [火]
■ [Other] ゼミの輪講
研究室のゼミで輪講の担当が回ってきました。音声生成とディジタル信号処理について。
音声生成で母音をどう扱うかだとか、アナログシステムをディジタルでどう扱おうかといったことです。教科書は音声・聴覚のための信号とシステム。これ厳密な説明というより、できるだけ数式を使わずにいかに分かりやすく理解するかということで良書です。
[ツッコミを入れる]
● Kabxenea [Due to the island city-state's mandatory death sentence we..]