HTML을 사용하여 JEditorPane에 이미지를 표시하는 방법
HTML 코드가 포함 된
JEditorPane에 이미지를 표시하려면이 솔루션이 잘 작동합니다 :
import javax.swing.*;
import java.awt.*;
class 이미지 확장 JFrame {
public static void main(String[] args) throws Exception {
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame 프레임 = new JFrame();
문자열 src = Image.class.getClassLoader().
getSystemResource("image.jpg").toString();
frame.getContentPane().add(new JEditorPane("text/html",
" < img src='"+src+"' 너비=280 높이=400> "));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}
출력: