メソッドからの出力として、文字列と a を表示しようとしていますBufferedImage
。JFrame
を画像から分離できないString
ため、両方を に追加する必要がありJFrame
ます。
ここに私がこれまでに行ったコードがあり、何も表示されていません。よろしくお願いいたします。
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);