Java 如何使用另一个JFrame中的JComboBox设置JFrame的背景颜色?

Java 如何使用另一个JFrame中的JComboBox设置JFrame的背景颜色?,java,computer-science,jcombobox,Java,Computer Science,Jcombobox,实际上,我正在为一个游戏做一个“设置”窗口,我想设置另一个窗口的背景色。我不知道该怎么办。一些想法请?为JPanel背景从属性设置不同的颜色您可以在不同的地方实现它。方法之一是构造函数,例如: public YourClassPanel() { // to set Look&Feel try { UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookA

实际上,我正在为一个游戏做一个“设置”窗口,我想设置另一个窗口的背景色。我不知道该怎么办。一些想法请?

JPanel
背景从
属性设置不同的颜色
您可以在不同的地方实现它。方法之一是构造函数,例如:

    public YourClassPanel() {
// to set Look&Feel    
            try {
                UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(ControlPanel.class.getName()).log(Level.SEVERE, null, ex);
            } catch (InstantiationException ex) {
                Logger.getLogger(ControlPanel.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                Logger.getLogger(ControlPanel.class.getName()).log(Level.SEVERE, null, ex);
            } catch (UnsupportedLookAndFeelException ex) {
                Logger.getLogger(ControlPanel.class.getName()).log(Level.SEVERE, null, ex);
            }
            SwingUtilities.updateComponentTreeUI(this);
            this.addWindowListener(new WindowAdapter() {
                @Override
                public void windowClosing(WindowEvent e) {
                    ControlPanel.tgp = null;
                }
            });

            this.setBounds(0, 0, 710, 580);
            this.setTitle("Buffer Allocation Panel");
            this.setPreferredSize(null);
            this.setResizable(false);

    this.setBackground(Color.yellow); //to set Background
    this.setForeground(Color.magenta); // to set Foreground
    this.setOpaque(a!=255); // to set Opaque

        }

我是Java的初学者,你能解释得更清楚些吗?可能是