package com.channelsoft.eps.test.epg; 

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

public class BtnFont extends JApplet implements ItemListener {

Container cp = getContentPane();

JLabel lb = new JLabel("班级:");

String str[] = { "101班", "102班", "103班", "104班", "105班" };

JButton bt = new JButton("请选择");

JComboBox cb = new JComboBox(str);


public void init() {

cp.setLayout(new FlowLayout());

cp.add(lb);

cp.add(bt);

cp.add(cb);

cb.addItemListener(this);

}


public void itemStateChanged(ItemEvent e) {

String str;

str = (String) e.getItem();

Font font = new Font("宋体", Font.PLAIN, 30);

bt.setText(str);

bt.setFont(font);

}


/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

BtnFont bt = new BtnFont();

bt.init();

}


}


结果:



  • j2se 下拉框变化字体_java

  • 大小: 3.8 KB
  • j2se 下拉框变化字体_java_02

  • 大小: 5 KB
  • ​​查看图片附件​​