java Swing 之列表框控件

时间:2014-05-03 17:28:28   收藏:0   阅读:404
/**
 * java Swing 列表框控件
 * @author gao
 */
package com.gao;

import java.awt.FlowLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

public class JListDemo extends JFrame{
       public JListDemo(){
    	   this.setTitle("列表框使用");
    	   this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    	   this.setBounds(100, 100, 250, 130);
    	   JPanel contentPane=new JPanel();
    	   contentPane.setBorder(new EmptyBorder(5,5,5,5));
    	   this.setContentPane(contentPane);
    	   contentPane.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
    	   JLabel label=new JLabel("证件类型:");
    	   contentPane.add(label);
    	   JList list=new JList(new String[]{"身份证","驾驶证","军官证"});
    	   contentPane.add(list);
    	   this.setVisible(true);
       }
       public static void main(String[]args){
    	   JListDemo example=new JListDemo();
       }
}
bubuko.com,布布扣

java Swing 之列表框控件,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!