问题:JMenuItem放入图标时,图片根据实际大小显示,根本无法满足需求:
item = new JMenuItem("打开", new ImageIcon("images/open.png"));
解决方法:
item = new JMenuItem("打开", new ImageIcon(new ImageIcon("images/open.png")
.getImage().getScaledInstance(16, 16, Image.SCALE_DEFAULT)));
new ImageIcon图像太大解决:
ImageIcon imageIcon = new ImageIcon("images/open.png"); imageIcon.setImage(imageIcon.getImage().getScaledInstance(16, 16, Image.SCALE_DEFAULT));