我有这段代码,当用户单击其中一种字体“粗体或斜体......”时,文本应该会改变。我无法添加将执行此操作的操作侦听器:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class question4 extends JFrame {
    private JTextField textField;
    private JComboBox fontbox;
    private String names[]={ "Bold","Italic","Plain"};
    private Icon icons[]={};
    public question4()
    {
        super("JcheckBox");
        setLayout(new FlowLayout());//set frame
        fontbox = new JComboBox(names);//set jcobobox
        fontbox.setMaximumRowCount(3);
        //listener
        add(fontbox);
        //add the text content
        textField = new JTextField ("Hello World", 20);
        textField.setFont(new Font("Calibri", Font.BOLD,18));//set the text font and size
        add(textField);//add textfield to jframe
    }
    public static void main(String args[])
    {
        question4 obj = new question4();//create object
        obj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        obj.setSize(700,400);
        obj.setVisible(true);
    }//end main
 }//end class