Getting error on line where HandlerClass implements ActionListener saying "Multiple markers at this line - Syntax error on tokens, delete these tokens - Syntax error, insert '}' to complete Block"
What I've got wrong there ?
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
public class Gui extends JFrame {
private JTextField tf;
private JCheckBox boldbox;
private JCheckBox italicbox;
public Gui() {
super("Hakuna Matata");
setLayout(new FlowLayout());
tf = new JTextField("This is a sentence");
tf.setFont(new Font("Serif", Font.PLAIN, 14));
add(tf);
boldbox = new JCheckBox("bold");
italicbox = new JCheckBox("italicbox");
add(boldbox);
add(italicbox);
HandlerClass handler = new HandlerClass();
boldbox.addActionListener(handler);
italicbox.addActionListener(handler);
}
private HandlerClass implements ActionListener {
public void ActionPerformed(ActionEvent event) {
Font font = null;
if(boldbox.isSelected() && italicbox.isSelected())
font = new Font("Serif", Font.BOLD + Font.ITALIC, 14);
else if(boldbox.isSelected())
font = new Font("Serif", Font.BOLD, 14);
else if(italicbox.isSelected())
font = new Font("Serif", Font.ITALIC, 14);
else
font = new Font("Serif", Font.PLAIN, 14);
tf.setFont(font);
}
}