【发布时间】:2012-11-20 23:43:58
【问题描述】:
我正在尝试在我的应用程序中显示图像...
picture = new JLabel("No file selected");
picture.setFont(picture.getFont().deriveFont(Font.ITALIC));
picture.setHorizontalAlignment(JLabel.CENTER);
scrollPane.setViewportView(picture);
ImageIcon icon = new ImageIcon("map.jpg");
picture.setIcon(icon);
if (picture.getIcon() != null) // to see if the label picture has Icon
picture.setText("HERE IS ICON");
当我运行该代码时,只显示“这里是图标”文本。 对不起,如果这个问题听起来很愚蠢,但我真的不知道为什么不显示图像图标:(
【问题讨论】: