更新时间:2023-12-04 10:09:04
您的图像文件需要与运行图像文件位于同一目录中来自。
Your image file needs to be in the same directory as you are running the application from.
如果它实际上与拨打电话的班级在同一目录中,那么你可以使用:
If its actually in the same directory as the class making the call then you can use:
searchIcon = new ImageIcon( getClass().getResource("searchIcon.png") );
如果它位于某个任意位置,那么您需要指定完整路径。
If it is in some arbitrary location then you will need to specify the full path.