Drop down box jcombobox, list box JList, scroll pane JScrollPane

From , 5 Years ago, written in Java, viewed 230 times.
URL https://pastebin.vip/view/56468d56
  1. /**
  2.  *功能:下拉框JComboBox,列表框 JList ,滚动窗格JScrollPane
  3.  */
  4.  
  5. package com.jiemian;
  6. import java.awt.*;
  7. import javax.swing.*;
  8.  
  9. public class Text7 extends JFrame{
  10.  
  11.         JPanel jp1,jp2;
  12.         JLabel jl1,jl2;
  13.         JComboBox jcb;
  14.         JList jlist;
  15.         JScrollPane jsp;
  16.         public static void main(String[] args) {
  17.                
  18.                 Text7 text7=new Text7();
  19.  
  20.         }
  21.        
  22.         public Text7(){
  23.                
  24.                 //创建组件
  25.                 jp1=new JPanel();
  26.                 jp2=new JPanel();
  27.                
  28.                 jl1=new JLabel("你的籍贯");
  29.                 jl2=new JLabel("旅游地点");
  30.                
  31.                 String []jg={"贺州","南宁","柳州","桂林","钦州","火星"};
  32.                 jcb=new JComboBox(jg);
  33.                
  34.                 String []dd={"九寨沟","天安门","故宫","长城","尧山","张家界"};
  35.                 jlist =new JList(dd);
  36.                 jlist.setVisibleRowCount(3);
  37.                 jsp=new JScrollPane(jlist);
  38.                
  39.                 //设置布局管理器
  40.                 this.setLayout(new GridLayout(2, 1));
  41.                
  42.                 //添加组件
  43.                 jp1.add(jl1);
  44.                 jp1.add(jcb);
  45.                
  46.                 jp2.add(jl2);
  47.                 jp2.add(jsp);
  48.                
  49.                 this.add(jp1);
  50.                 this.add(jp2);
  51.                
  52.                 //设置窗体属性
  53.                 this.setSize(300, 200);
  54.                 this.setTitle("用户调查");
  55.                 this.setIconImage((new ImageIcon("images\\head_boy.jpg")).getImage());
  56.                 this.setLocation(300, 300);
  57.                 this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  58.                 this.setVisible(true);
  59.                
  60.                
  61.                
  62.                
  63.                
  64.         }
  65.  
  66. }
  67.  

Reply to "Drop down box jcombobox, list box JList, scroll pane JScrollPane"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website