Font.PLAIN - Isn't setting Font back to a Plain Style - Need Help!
Here's a small snipit of the code i've created;
My problem:
-When bold and italic are both false, the font refuses to reset to plain and remains bold. Code:
public void setStyle(Boolean bold, Boolean italic){
if(bold == true && italic == false)
lblMain.setFont(new Font(lblMain.getFont().getFontName(), Font.BOLD, lblMain.getFont().getSize()));
else if(bold == false && italic == true){
lblMain.setFont(new Font(lblMain.getFont().getFontName(), Font.ITALIC, lblMain.getFont().getSize()));
}
else if(bold ==true && italic == true){
lblMain.setFont(new Font(lblMain.getFont().getFontName(), Font.BOLD+Font.ITALIC, lblMain.getFont().getSize()));
}
else if(bold == false && italic == false){
lblMain.setFont(new Font(lblMain.getFont().getFontName(), Font.PLAIN, lblMain.getFont().getSize()));
}
}
here is the code that calls the above method:
(the below code is present in the actionPerformed method of a JFrame that implements ActionListener)
Code:
else if(event.getSource() == chkBold || event.getSource() == chkItalic){
setStyle(chkBold.isSelected(), chkItalic.isSelected());
}