如题~!

解决方案 »

  1.   


    参考 JMenuItem 的JDK文档public JMenuItem(String text, Icon icon) Creates a JMenuItem with the specified text and icon. Parameters:
    text - the text of the JMenuItem
    icon - the icon of the JMenuItem其中icon是实现了Icon接口的某个类,可以使用ImageIcon这个类。参考它的JDK文档,用这个构造函数创建一个ImageIcon对象:ImageIcon(String filename) 
    Creates an ImageIcon from the specified file.接下来的这一步并不是一定需要的,但是没有调试过,我也不是很确定
    将 ImageIcon 对象Wrap到一个 IconUIResource 对象IconUIResource(Icon delegate) 
    Creates a UIResource icon object which wraps an existing Icon instance.然后将 IconUIResource 对象作为参数传递给JMenuItem的构造函数换一句话说,直接用 ImageIcon 对象构造 JMenuItem 行得通的话,就不需要使用IconUIResource参数了。