码迷,mamicode.com
首页 > 其他好文 > 详细

实验十二

时间:2019-06-16 22:04:13      阅读:104      评论:0      收藏:0      [点我收藏+]

标签:set   etl   网络   frame   dac   rod   java   nta   size   

代码如下:

package information;
 
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
 
class information extends JFrame
{
    public information()
    {
        JFrame a=new JFrame();
        a.setLayout(new FlowLayout());
        a.setTitle("Introduction");
        a.setSize(400,100);
        a.setLocation(300,240);
        String proList[] = { "姓名","性别","年龄","民族" ,"籍贯","学号","学院","专业"};
        JComboBox comboBox;
        Container conPane = getContentPane();  
        comboBox = new JComboBox(proList);   
        comboBox.setEditable(true);    
        conPane.add(comboBox);
        JTextField b=new JTextField(20);
        a.add(conPane);
        a.add(b);
        comboBox.addActionListener(new ActionListener()
                {public void actionPerformed(ActionEvent e)
                {  if(comboBox.getSelectedItem().equals("姓名"))
                    b.setText("王菁源");
                else if(comboBox.getSelectedItem().equals("性别"))
                    b.setText("女");
                else if(comboBox.getSelectedItem().equals("年龄"))
                    b.setText("21");
                else if(comboBox.getSelectedItem().equals("民族"))
                    b.setText("汉族");
                else if(comboBox.getSelectedItem().equals("籍贯"))
                    b.setText("河北省新乐市");
                else if(comboBox.getSelectedItem().equals("学号"))
                    b.setText("20173311142");
                else if(comboBox.getSelectedItem().equals("学院"))
                    b.setText("计算机学院");
                else if(comboBox.getSelectedItem().equals("专业"))
                    b.setText("网络工程");
                }
                    });
        a.setVisible(true);
    }
        }
 
public class information {
    public static void main(String[] args)
    {
            new introduce();
            }
}

实验十二

标签:set   etl   网络   frame   dac   rod   java   nta   size   

原文地址:https://www.cnblogs.com/JinnyWang/p/11032902.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!