Java 挫折地不';我不能在Windows7中工作

Java 挫折地不';我不能在Windows7中工作,java,swing,background,jcombobox,Java,Swing,Background,Jcombobox,我正在尝试使用setBackground将JComboBox的背景色更改为红色。它在windows XP中工作,但在windows 7中不工作。我尝试了以下所有解决方案: 这是我的密码: public class HelloWorld { public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getCross

我正在尝试使用
setBackground
JComboBox
的背景色更改为红色。它在windows XP中工作,但在windows 7中不工作。我尝试了以下所有解决方案:

这是我的密码:

public class HelloWorld
{
    public static void main(String[] args)
    {
        try
        {
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
            JFrame hello = new JFrame("Hello World");
            JComboBox combo = new JComboBox();
            combo.setBackground(Color.red);
            combo.setOpaque(true);
            hello.add(combo);
            hello.pack();
            hello.setVisible(true);
        }
        catch (ClassNotFoundException ex)
        {
            Logger.getLogger(HelloWorld.class.getName()).log(Level.SEVERE, null,
                    ex);
        }
    }
}

我刚刚运行了你的代码,它在我的Windows7系统(64位)上运行良好。 所以我想知道,你的Windows7系统可能出了什么问题


我会尝试在那台机器上重新安装Java

考虑创建并发布您的。您确定在创建框架和组合框之前设置了外观吗?在先前的问题修订中,你把它反过来了。这是个问题。试试这个小应用:我看不出这个问题的原因,请阅读JComboBox和JComboBox、JList或JTable中的rendering概念(非常相似的概念),可编辑和不可编辑的JComboBox的逻辑是不同的