
I have created a welcome page and when I try to change the font style of the label named lblCName it does not change.Indentify the reason for this and make changess
import javax.swing.border.*; import java.awt.Color; import java.awt.Image; import java.awt.Toolkit; import java.awt.Graphics; import java.awt.Font;
public class WelcomePage extends JApplet { JPanel mnPanel,svrsPanel; JLabel lblCName, lblServices, lblCHistory, lblCLogo; JButton viewProd, placeOrdr; Icon image; Font fnt;
public void init(){ fnt=new Font("Verdana", Font.BOLD, 18); lblCName.setfont(fnt); } }

Java JLabel set font
import java.awt.*;
import javax.swing.*;
class LabelExample
{
public static void main(String[] args)
{
JFrame f=new JFrame();
f.setLayout(null);
JLabel l=new JLabel("Hello");
l.setFont(new Font(null,Font.BOLD,30));
l.setBounds(20,20,120,50);
l.setForeground(Color.red);
f.add(l);
f.setVisible(true);
f.setSize(300,100);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.