0

ここで見つけました:探していたものですが、まだいくつか問題があります。

これは私のアクションコードです:

private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) throws IOException {

    jEditorPane1.setContentType("text/html");


    int returnVal = FileChooser1.showOpenDialog(this);
    if (returnVal == FileChooser1.APPROVE_OPTION) {


String image = String.format("<img src=\"%s\">", FileChooser1.getSelectedFile());
    jEditorPane1.setText(image);

    }
}

画像がロードされていないことがわかるように、何が起こるかのスクリーンショットを次に示します。 http://postimg.org/image/agc665ih1/

しかし、(保存ボタンで) ファイルを保存し、同じファイルを (開くボタンで) 再度開くと、画像がそこにあり、完全に読み込まれます。

私はすでに .repaint() および .revalidate() メソッドを試しましたが、機能していません..何か考えはありますか?

4

3 に答える 3

0

これは、JEditorPane ページでパスを設定する際の問題である可能性があります。これを使って:

String image = String.format("<img src=\"%s\">", FileChooser1.getSelectedFile().getPath());

JEdi​​torPane に適切な editorKit を既に選択していると仮定しています。

于 2013-08-12T10:36:57.070 に答える