Java-将图像转换为Icon / ImageIcon?

我有一个Image对象,我想将其转换为Icon或ImageIcon以添加到JTextPane。我将如何去做呢?(这是在JAVA中)

澄清:我的“图像”是图像对象的实例,而不是文件。

回答:

这有什么错new

ImageIcon(Image)

Image img = ...

ImageIcon icon = new ImageIcon(img);

以上是 Java-将图像转换为Icon / ImageIcon? 的全部内容, 来源链接: utcz.com/qa/403960.html

回到顶部