我正在尝试编写一个聊天客户端(多线程),它应该能够在主聊天窗口(我的情况下是JTextArea)中显示图像(由服务器发送)?有没有办法直接这样做,或者我必须编码和解析我的图像。例如,Facebook聊天可让您直接拖放图像并在主聊天窗口中显示它们。如果我们不能用Java做到这一点,请建议一些其他可用的环境。
答案 0 :(得分:3)
我认为JTextPane可以更好地满足您的需求:http://docs.oracle.com/javase/tutorial/uiswing/components/editorpane.html
答案 1 :(得分:0)
有效:
JTextPane t = new JTextPane();
t.setContentType("text/html");
t.setText("<html><img src='" + Hello.class.getClassLoader().getResource("hello.gif").toString() + "'/></html>");