【GUI组件】ComboBox

GUI组件——组合框 ComboBox

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package x_08;
import java.awt.*;
import javax.swing.*;

/**
 *
 * @author Administrator
 */
public class ComboBox extends JFrame{
    public ComboBox(){
        super("组合框—ComboBox");
        setSize(250,300);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
        FlowLayout flo=new FlowLayout();
        setLayout(flo);
        
        JComboBox profession=new JComboBox();
        profession.addItem("Butcher");
        profession.addItem("Baker");
        profession.addItem("Candlestck maker");
        profession.addItem("Flecher");
        profession.addItem("Flighter");
        profession.addItem("Technical writer");
        add(profession);
         //profession.setEditable(true);//接受文本输入
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
    ComboBox sal=new ComboBox();

    }

}
运行截图:

【GUI组件】ComboBox_第1张图片

你可能感兴趣的:(java/J2SE/J2EE)