import javax.swing.*;
import java.awt.*;
import java.awt.event.*;public class TextPanel extends JFrame{
    JComboBox jComboBox1 = new JComboBox();
    JScrollPane jScrollPane1 = new JScrollPane();
    JTextPane jTextPane1 = new JTextPane();
    public TextPanel() {
        try {
          jbInit();
        }
        catch(Exception e) {
          e.printStackTrace();
        }
    }
    public static void main(String[] args) {
        TextPanel textPanel1 = new TextPanel();
        textPanel1.setSize(400,300);
        textPanel1.setVisible(true);
        textPanel1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    private void jbInit() throws Exception {
      this.getContentPane().setLayout(null);
      jComboBox1.setBounds(new Rectangle(59, 20, 209, 18));
      jComboBox1.addItem("3");
      jComboBox1.addItem("5");
      jComboBox1.addItem("7");
      jScrollPane1.setBounds(new Rectangle(39, 84, 331, 179));
      jTextPane1.setText("jTextPane1");
      this.getContentPane().add(jComboBox1, null);
      this.getContentPane().add(jScrollPane1, null);
      jScrollPane1.getViewport().add(jTextPane1, null);
      jComboBox1.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
             if(jComboBox1.getSelectedItem().equals("3")){
                 jTextPane1.setFont(new Font("华文彩云", Font.PLAIN, 13));
                 jTextPane1.setForeground(Color.red);
          }else if(jComboBox1.getSelectedItem().equals("5")){
              jTextPane1.setFont(new Font("宋体", Font.ITALIC, 18));
              jTextPane1.setForeground(Color.BLUE);
          }
          else if(jComboBox1.getSelectedItem().equals("7")){
              jTextPane1.setFont(new Font("黑体", Font.BOLD, 5));
              jTextPane1.setForeground(Color.green);
          }
      }
    });
    }
}