Hello =)

I have some problem to set font and color in my program.can you take a look for the moment please?Here is my simple program:

import java.awt.event.*;
import javax.swing.*;

public class showYourLove extends JFrame
//inherits from JFrame class
{
private JPanel panel; //to references a panel
private JLabel msgLabel;//to reference a label
private JTextField LoveTxtField;//to reference a text field
private JButton Button;//to reference a button
private JLabel picLabel;
private final int width=400;//window width
private final int height=600;//window height

public showYourLove() //constructor
{
   setTitle("Show Your Love !");
   setSize(width,height);
   setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   buildPanel();
   add(panel);
   setVisible(true);


}

private void buildPanel(){

//method that adds a lable,textfield and button


 JLabel msgLabel= new JLabel("Show your love to your Mom by type I love You Mom");
 msgLabel.setFont(new Font("Serif", Font.BOLD, 14));
 msgLabel.setForeground(Color.blue);


    LoveTxtField=new JTextField(10);
    Button=new JButton("Done");
    JLabel picLabel=new JLabel(new ImageIcon("C:\\Documents and Settings\\User\\My Documents\\JCreator LE\\MyProjects\\LibGui\\showYourLove\\src\\love.GIF"));
	



	
	
    //add an action listener to the button,below the code in which you declare a button of type JButton in the buildPanel() method.

Button.addActionListener(new ButtonListener());
    panel=new JPanel();
    panel.add(msgLabel);
    panel.add(LoveTxtField);
    panel.add(Button);
    panel.add(picLabel);
    
    
    
        
    
}

private class ButtonListener implements ActionListener
{
	public void actionPerformed(ActionEvent e)
	{
		
		
		String actionCommand=e.getActionCommand();

	
			//Display the result
			
			JOptionPane.showMessageDialog(null,"Thank you for showing your love here.");
		
	}
}


public static void main(String[]args)


{

    showYourLove love = new showYourLove();

}
}

So what's wrong with this code??

msgLabel.setFont(new Font("Serif", Font.BOLD, 14));

Its not working??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.