Sunday, February 7, 2016

Program to change backcolor and textcolor of label using color class.

import java.awt.*;
class Demo4_ColorLabel extends Frame
{
public static void main(String args[ ] )
{
Color c1 =new Color(200, 100,50);
Color c2=new Color(100,150,250);
Label l1 =new Label("Java is lnteresting!!!");
//setting text color of label
l1.setForeground(c1 );
//setting background color of a label
l1.setBackground(c2);
Demo4_ColorLabel f1 =new Demo4_ColorLabel();
f1.setTitle("Working with colors of a Label");
f1.add(l1);
f1.resize(400,200);
f1.show();
}
}
Output:

No comments:

Post a Comment