当前位置:网站首页>Simulated student information input interface
Simulated student information input interface
2022-07-22 20:37:00 【Small eleven acridine】
A student information input interface is attached
`package cy;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
@SuppressWarnings(“serial”)
public class StudentLogin extends JFrame implements ActionListener{
JButton jb1=new JButton(“ determine ”);
JButton jb2=new JButton(“ sign out ”);
JLabel jl1= new JLabel(“ The student's name :”);
JTextField jtf = new JTextField(20);
JLabel jl2= new JLabel(“ sex other :”);
// JTextField jpf = new JTextField(20);
String[] listData = new String[]{“ male ”,“ Woman ”};
final JComboBox comboBox = new JComboBox(listData);
public StudentLogin(){
JFrame jf=new JFrame(" Student information input window ");
jf.setSize(400, 300);
JPanel mainpanel=new JPanel();
JLayeredPane layeredPane = new JLayeredPane();
layeredPane.setBounds(0, 0, 600, 544);
mainpanel.setBounds(5, 50, 400, 190);
mainpanel.setLayout(new GridLayout(4,1));
// GridLayout layout = new GridLayout(1,2);
// Set up level and vertical The gap
// layout.setHgap(10);
JPanel jp1=new JPanel();
JPanel jp2=new JPanel();
// JPanel jp3=new JPanel(layout);
JPanel jp3=new JPanel();
Font font = new Font(“ In black ”,Font.PLAIN,20);
jl1.setFont(font);
jtf.setFont(font);
jl2.setFont(font);
jp3.setFont(font);
jp1.add(jl1);
jp1.add(jtf);
jp2.add(jl2);
comboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
// Process only the selected status
if (e.getStateChange() == ItemEvent.SELECTED) {
// System.out.println(" Choose : " + comboBox.getSelectedIndex() + " = " + comboBox.getSelectedItem());
}
}
});
// Set the default selected entry
comboBox.setSelectedIndex(0);
// Add to content panel
jp2.add(comboBox);
jp3.add(jb1);
jp3.add(jb2);
mainpanel.add(jp1);
mainpanel.add(jp2);
mainpanel.add(jp3);
layeredPane.add(mainpanel);
jf.add(layeredPane);
jf.setLocationRelativeTo(null);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setVisible(true);
jf.setResizable(false);
jb1.addMouseListener(new MouseAdapter(){
@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
message();
}
});
jb2.addMouseListener(new MouseAdapter(){
@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
System.exit(0);
}
});
}
public void message(){
String str= " The student's name :"+ jtf.getText()+
"; Gender :"+ comboBox.getSelectedItem();
JOptionPane.showMessageDialog(this,str);
}
@SuppressWarnings("unused")
public static void main(String[] args) {
// TODO Auto-generated method stub
StudentLogin Student_Login=new StudentLogin();
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
}
`
边栏推荐
- DEFORMABLE DETR 论文精度,并解析网络模型结构
- Her power series II UCLA Li Jingyi: the last thing women need to do is "doubt themselves"
- 1080 graduate admission (30 points)
- Pre training weekly 39: deep model, prompt learning
- 1076 Forwards on Weibo (30 分)
- LeetCode53——Maximum Subarray——3 different methods
- 1045 favorite color stripe (30 points)
- Leetcode0002——Add Two Numbers——Linked List
- MySQL index
- 八大排序(直接插入排序)
猜你喜欢
随机推荐
她力量系列五丨朱海一:以人为本,构建 AI 价值观
Vim学习之旅
Leetcode0002——Add Two Numbers——Linked List
1064 Complete Binary Search Tree (30 分)
Notes: C language
C language unsigned int and int
1049 Counting Ones (30 分)
Leetcode206 - reverse linked list
sql优化技巧及注意事项
Latex compiles and reports errors in vscode `recipe terminated with error Retry building the project.
7-3 Size of Military Unit (25 分)
1072 gas station (30 points)
Introduction to machine learning: Logistic regression-2
7-1 fake news (20 points)
八大排序(直接插入排序)
LeetCode912——sort an array—— quick sort algorithm
Guidelines for installation and use of Damon database
【文献阅读与想法笔记13】Pre-Trained Image Processing Transformer
16进制字符串与字节数组之间的转换
IDEA 隐藏.idea文件夹 隐藏.iml文件