new Color(int r, int g, int b) : Color « java.awt « Java by API






new Color(int r, int g, int b)

  

import java.awt.BorderLayout;
import java.awt.Color;

import javax.swing.JButton;
import javax.swing.JFrame;

public class Main {
  public static void main(String args[]) {
    JFrame f = new JFrame("JColorChooser Sample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final JButton button = new JButton("Pick to Change Background");
    Color myBlack = new Color(0,0,0);           // Color black
//    Color myWhite = new Color(255,255,255);     // Color white
  //  Color myGreen = new Color(0,200,0);         // A shade of green
    
    button.setBackground(myBlack);
    f.add(button, BorderLayout.CENTER);
    f.setSize(300, 200);
    f.setVisible(true);
  }
}

   
    
  








Related examples in the same category

1.Color.GRAY
2.Color.lightGray
3.Color.magenta
4.Color.pink
5.new Color(int rgb)
6.Color: equals(Object obj)
7.Color: getComponents(float[] compArray)
8.Color: getRGB()
9.Color: HSBtoRGB(float hue,float saturation,float brightness)
10.Color: RGBtoHSB(int r, int g, int b, float[] hsbvals)