我想在我的應用程序中顯示的圖像...JLabel的圖標未顯示
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");
當我運行的代碼,只有「這裏是ICON」顯示的文本。 對不起,如果這個問題聽起來很愚蠢,但我真的不知道爲什麼圖像圖標不顯示:(
謝謝...現在得到它:)我多麼愚蠢:) – Ken