请教前辈们一个问题,望不吝赐教
public class Test {
public static void main(String[] args) {
ImageIcon imgIcon = new ImageIcon("F:\\Desktop\\External\\图片");①
System.out.println(imgIcon.getIconWidth());
System.out.println(imgIcon.getIconHeight());
// 打印结果-1 -1
JFileChooser chooser = new JFileChooser("F:\\Desktop\\External\\图片");
int choice = chooser.showOpenDialog(null);
imgIcon = new ImageIcon(chooser.getSelectedFile().getPath());②
System.out.println(imgIcon.getIconWidth());
System.out.println(imgIcon.getIconHeight());
//打印结果380 230
}
}
问题描述:chooser.getSelectedFile().getPath()这个得到的不是路径吗?这里imgIcon为什么不和①一样为null,这里面的机制不懂,求各种前辈各种指教!感激涕零啊!