/** |
*功能:下拉框JComboBox,列表框 JList ,滚动窗格JScrollPane |
*/ |
package com.jiemian; |
import java.awt.*; |
import javax.swing.*; |
public class Text7 extends JFrame{ |
JPanel jp1,jp2; |
JLabel jl1,jl2; |
JComboBox jcb; |
JList jlist; |
JScrollPane jsp; |
public static void main(String[] args) { |
|
Text7 text7= new Text7(); |
} |
|
public Text7(){ |
|
//创建组件 |
jp1= new JPanel(); |
jp2= new JPanel(); |
|
jl1= new JLabel( "你的籍贯" ); |
jl2= new JLabel( "旅游地点" ); |
|
String []jg={ "贺州" , "南宁" , "柳州" , "桂林" , "钦州" , "火星" }; |
jcb= new JComboBox(jg); |
|
String []dd={ "九寨沟" , "天安门" , "故宫" , "长城" , "尧山" , "张家界" }; |
jlist = new JList(dd); |
jlist.setVisibleRowCount( 3 ); |
jsp= new JScrollPane(jlist); |
|
//设置布局管理器 |
this .setLayout( new GridLayout( 2 , 1 )); |
|
//添加组件 |
jp1.add(jl1); |
jp1.add(jcb); |
|
jp2.add(jl2); |
jp2.add(jsp); |
|
this .add(jp1); |
this .add(jp2); |
|
//设置窗体属性 |
this .setSize( 300 , 200 ); |
this .setTitle( "用户调查" ); |
this .setIconImage(( new ImageIcon( "images\\head_boy.jpg" )).getImage()); |
this .setLocation( 300 , 300 ); |
this .setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
this .setVisible( true ); |
|
|
|
|
|
} |
} |