Код: Выделить всё
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JTextPane;
public class App extends JFrame {
private void run() {
setSize(new Dimension(320, 240));
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JTextPane pane = new JTextPane();
pane.setContentType("text/html");
String imageUrl = getClass()
.getClassLoader()
.getResource("resources/img.jpg");
pane.setText(
""+
" "+
// CSS works perfectly for text,
".text { color: red; font-family: \"Times New Roman\"; }"+
// but not for images
".pic { width: 250px; }"+
" "+
""+
" Aaaa.
"+
"
[img]\[/img]
"+
""+
""
);
getContentPane().add(pane);
setVisible(true);
};
public App() {
super("Test HTML+CSS");
}
public static void main(String[] args) {
App app = new App();
app.run();
}
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... java-swing