How can I declare JCheckBox
so that when it's checked it will change the JLabel
text to uppercase?
I've been trying many things yet nothing works
public void itemStateChanged(ItemEvent e) {
Font f = null;
if(Bold.isSelected() && Italic.isSelected())
f = new Font("Serif", Font.BOLD + Font.ITALIC, 14);
else if(Bold.isSelected())
f = new Font("Serif", Font.BOLD, 14);
else if(Italic.isSelected())
f = new Font("Serif", Font.ITALIC, 14);
if(Capitalized.isSelected()){
}
label3.setFont(f);
}
What should put inside if(Capitalized.isSelected())
?
Have you tried getting the text, then calling toUpperCase() on it:
label3.setText(label3.getText().toUpperCase());