I am trying to display a string and a BufferedImage
onto a JFrame
that both come as output from a method. I am not able to separate the String
from the image, therefore I need to add both to the JFrame
.
Here is the code I have do far and nothing is displaying. Thank you very much for your help in advance.
String path = getUserInfo("abc123"); <-- method that returns a string and a buffered image
BufferedImage image = null;
try {
image = ImageIO.read(new File(path));
} catch (IOException ex) {
Logger.getLogger(InstagramClient.class.getName()).log(Level.SEVERE, null, ex);
}
JFrame f = new JFrame();
f.setSize(400,400);
f.setVisible(true);
ImageIcon icon = new ImageIcon(image);
JLabel label = new JLabel(icon, JLabel.CENTER);
JOptionPane.showMessageDialog(null, label, "icon", -1);