Q.Write a java program to display Label with text “Dr. D Y Patil College”, background color Red and font size 20 on the frame. [15M]
import java.awt.*;
public class LabelDemo extends Frame {
LabelDemo() {
// Create Label
Label lbl = new Label("Dr. D Y Patil College", Label.CENTER);
// Set background color
lbl.setBackground(Color.RED);
// Set font size and style
Font f = new Font("Arial", Font.BOLD, 20);
lbl.setFont(f);
// Set label position
lbl.setBounds(50, 100, 300, 40);
add(lbl);
setSize(400, 300);
setLayout(null);
setTitle("Label Demo");
setVisible(true);
}
public static void main(String[] args) {
new LabelDemo();
}
}