设计个人介绍界面(用SWING控件)
2021-05-30 17:24
标签:als ble ane else rod 网络 通过 table content 这里不再一一显示截图 源码如下: 心得总结: 通过本次实验学会了使用SWING组件,并将其添加到图形界面。 设计个人介绍界面(用SWING控件) 标签:als ble ane else rod 网络 通过 table content 原文地址:https://www.cnblogs.com/fjcy/p/11032594.htmlpackage introduce;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
class introduce extends JFrame
{
public introduce()
{
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("20");
else if(comboBox.getSelectedItem().equals("民族"))
b.setText("汉");
else if(comboBox.getSelectedItem().equals("籍贯"))
b.setText("河南 洛阳");
else if(comboBox.getSelectedItem().equals("学号"))
b.setText("20173311133");
else if(comboBox.getSelectedItem().equals("学院"))
b.setText("计算机学院");
else if(comboBox.getSelectedItem().equals("专业"))
b.setText("网络工程");
}
});
a.setVisible(true);
}
}
public class Introduction {
public static void main(String[] args)
{
new introduce();
}
}
文章标题:设计个人介绍界面(用SWING控件)
文章链接:http://soscw.com/index.php/essay/89630.html