質問内容
質問を評価する
(0ポイント)
|
こんにちは。 Eclipseを使ってプログラミングをしているJava初心者 です。
今回 初めてJTextPaneというものを使ってみたのですが フォントの設定が上手く変更できず、詰まってしまいま した。
昨日から丸一日APIを読んだりぐぐったりして 以下のようなコードを見つけたので使ってみたのですが
どちらもデバッグモードでは正常に作動する反面、 何故かRunnable JARでExportすると変更した設定がまっ たく適用されていないのです。
JTextPane text = new JTextPane(); SimpleAttributeSet attribs = new SimpleAttributeSet(); StyleConstants.setAlignment(attribs, StyleConstants.ALIGN_LEFT); StyleConstants.setFontFamily(attribs, "Consolas");
[方法1] text.setParagraphAttributes(attribs, true); text.setText("...");
[方法2] StyledDocument doc = text.getStyledDocument(); doc.setParagraphAttributes(0, doc.getLength(), attribs, true); try { doc.insertString(doc.getLength(), "...", null); } catch(BadLocationException ble) {}
add(text);
今もずっと方法を探しているのですが、殆ど手詰まり状 態です。 恐縮ですが、少しアドバイスをお願いできますでしょう か。
|