Java Color(float r, float g, float b) Constructor
Syntax
Color(float r, float g, float b) constructor from Color has the following syntax.
public Color(float r, float g, float b)
Example
In the following code shows how to use Color.Color(float r, float g, float b) constructor.
/* w ww . ja v a 2 s . c om*/
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Main {
public static void main(String[] args) {
Color myColor = new Color(0.1F,0.2F,0.3F);
JLabel label = new JLabel("First Name");
label.setForeground(myColor);
JFrame frame = new JFrame();
frame.add(label);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setBounds(20,20, 500,500);
frame.setVisible(true);
}
}
Home »
Java Tutorial »
java.awt »
Java Tutorial »
java.awt »