在要变地方
if(x ==1)
{
 JLabel1.setForegroud(Color.red) ;
 }

解决方案 »

  1.   

    contentPane = (JPanel) this.getContentPane();
        contentPane.setLayout(new FlowLayout());
        JLabel jl=new JLabel("HelloWorld");
        jl.setText("jTextField1");
        contentPane.add(jl);
        Color[] color=new Color[]{
          new Color(00,00,00),
          new Color(255,00,00),
          new Color(00,255,00),
          new Color(00,00,255)
        };
        JComboBox jcb=new JComboBox(new String[]{"1","2","3","4"});
        jcb.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Frame1.this.jl.setForeground(Frame1.this.color[((JComboBox)e.getSource()).getSelectedIndex()]);
            Frame1.this.validate();
          }
        });
        contentPane.add(jcb);