这是颜色的常量,自己设定的呀...
static Color black 
          The color black. 
static Color BLACK 
          The color black. 
static Color blue 
          The color blue. 
static Color BLUE 
          The color blue. 
static Color cyan 
          The color cyan. 
static Color CYAN 
          The color cyan. 
static Color DARK_GRAY 
          The color dark gray. 
static Color darkGray 
          The color dark gray. 
static Color gray 
          The color gray. 
static Color GRAY 
          The color gray. 
static Color green 
          The color green. 
static Color GREEN 
          The color green. 
static Color LIGHT_GRAY 
          The color light gray. 
static Color lightGray 
          The color light gray. 
static Color magenta 
          The color magenta. 
static Color MAGENTA 
          The color magenta. 
static Color orange 
          The color orange. 
static Color ORANGE 
          The color orange. 
static Color pink 
          The color pink. 
static Color PINK 
          The color pink. 
static Color red 
          The color red. 
static Color RED 
          The color red. 
static Color white 
          The color white. 
static Color WHITE 
          The color white. 
static Color yellow 
          The color yellow. 
static Color YELLOW 
          The color yellow. 

解决方案 »

  1.   

    代码如下:import java.awt.*;
    import javax.swing.*;public class aa extends JFrame
    {
    public static void main(String args[])
    {
    aa d = new aa();
    d.getContentPane().setBackground(Color.black);
    d.setSize(200, 200);
    d.setVisible(true);
    }
    }
      

  2.   

    上面两位大侠能不能告诉我setBackground()和setForeground()这两个方法是设置哪部分的颜色??有什么作用?
      

  3.   

    我是这么设置全屏的:
      GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
      GraphicsDevice device = environment.getDefaulScreenDevice();  DisplayMode displaymode;
      
      device.setFullScreenWindow(frame);// frame extends from JFrame;
      device.setDeviceDiplayMode(displaymode);  setBackground(Color.black);
      setForeground(Color.black);
      Graphics g = this.getGraphics();
      g.setColor(Color.red);
      g.drawString("Hello World!", 20, 50);
      g.dispose();
    但却不能正常显示黑色的背景,怎么回事?