要在Eclipse项目的包里添加图片,可以按照以下步骤进行操作:
String imagePath = getClass().getResource("/image.jpg").toString();
ImageIcon imageIcon = new ImageIcon(getClass().getResource("/image.jpg"));
JLabel label = new JLabel(imageIcon);
通过以上步骤,就可以在Eclipse项目的包里添加图片,并在代码中使用这些图片。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:eclipse中如何添加jar包