I have been programming this small app that the user can select one of the a font colors, blue , red and black, so i used JradioButton for them. also the user can choose a style to the font whether bold or italic or both at the same time, so i used Jcheckbox. the problem is that i tried to let the user choose both italic and bold but nothing changed, is there a way to do that?
private void jRadioBlackActionPerformed(java.awt.event.ActionEvent evt) {
if (jRadioBlack.isSelected()) {
jTextField1.setForeground(Color.black);
}
if (jCheckBoxBold.isSelected() && jCheckBoxItalic.isSelected()) {
jTextField1.setFont(new Font("Times New Roman", Font.BOLD + Font.ITALIC, 14));
}
}
private void jRadioRedActionPerformed(java.awt.event.ActionEvent evt) {
if (jRadioRed.isSelected())
jTextField1.setForeground(Color.red);
}
private void jRadioBlueActionPerformed(java.awt.event.ActionEvent evt) {
if (jRadioBlue.isSelected())
jTextField1.setForeground(Color.blue);
}
private void jCheckBoxBoldItemStateChanged(java.awt.event.ItemEvent evt) {
if (jCheckBoxBold.isSelected()) {
jTextField1.setFont(new Font("Times New Roman", Font.BOLD, 14));
} else {
jTextField1.setFont(new Font("Times New Roman", Font.PLAIN, 14));
}
}
private void jCheckBoxItalicStateChanged(javax.swing.event.ChangeEvent evt) {
}
private void jCheckBoxItalicItemStateChanged(java.awt.event.ItemEvent evt) {
if (jCheckBoxItalic.isSelected()) {
jTextField1.setFont(new Font("Times New Roman", Font.ITALIC, 14));
} else {
jTextField1.setFont(new Font("Times New Roman", Font.PLAIN, 14));
}
}