I have an Image object that I would like to convert to an Icon or ImageIcon to add to a JTextPane. How would I go about doing this? (this is in JAVA)
clarification: my "Image" is an instance of the Image Object, not a File.
What's wrong with new ImageIcon(Image)?
Image img = ...
ImageIcon icon = new ImageIcon(img);
    Add the image to your JTextPane document:
Image image = ImageIO.read(new File("myImage.jpg"));
StyleContext context = new StyleContext();
StyledDocument document = new DefaultStyledDocument(context);
Style labelStyle = context.getStyle(StyleContext.DEFAULT_STYLE);
Icon icon = new ImageIcon(image);
JLabel label = new JLabel(icon);
StyleConstants.setComponent(labelStyle, label);
document.insertString(document.getLength(), "Ignored", labelStyle);
JTextPane textPane = new JTextPane(document);
    Try this...
Toolkit t = Toolkit.getDefaultToolkit();
Image i = t.getImage("icon.gif");
setIconImage(i);
    Shubham Goswami
ImageIcon icon=null; 
ImageIcon imageicon = new ImageIcon("C:\\Winter.jpg");
if (imageicon != null) {
    if (imageicon.getIconWidth() > 60) {
        System.out.println(jLabel1.getWidth());
        icon = new ImageIcon(imageicon.getImage().getScaledInstance(26, -1, Image.SCALE_DEFAULT));
    } else {
        icon = imageicon;
}
jLabel1.setIcon((Icon) icon);
    来源:https://stackoverflow.com/questions/12020597/java-convert-image-to-icon-imageicon