界面系统运行界面03--java
来源:互联网 发布:手机淘宝群网页版 编辑:程序博客网 时间:2024/06/08 10:08
紧接02的代码继续写,接下去是进入到专业班级。不同按钮转到不同的界面。在02中有student,teacher,leader三类;本代码实现了studentmanageframe,剩下的teacher和leader读者自己完成,完全一样。完成这个之后已经成功了一大半,接下来是需要链接到数据库将数据导入。
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class studentmanageframe extends JPanel {
static final int WIDTH = 400;
static final int HEIGHT = 200;
//JFrame buttonframe;
public void add(Component c, GridBagConstraints constraints, int x, int y, int w, int h){ constraints.gridx = x; constraints.gridy = y; constraints.gridwidth = w; constraints.gridheight = h; add(c,constraints);}public studentmanageframe(){ JFrame studentframe = new JFrame("学生信息管理系统"); //buttonframe.setTitle("学校信息管理系统"); studentframe .setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); studentframe.setSize(WIDTH, HEIGHT); Toolkit kit = Toolkit.getDefaultToolkit(); //获取屏幕的大小对象 Dimension screenSize = kit.getScreenSize(); int width = screenSize.width; int height = screenSize.height; int x = (width-WIDTH)/2; int y = (height - HEIGHT)/2; studentframe.setLocation(x, y); studentframe.setVisible(true); studentframe.add(this, BorderLayout.CENTER); JButton computerone = new JButton("计算机一班"); JButton computertwo = new JButton("计算机二班"); JButton computerthree = new JButton("计算机三班"); JButton bioone = new JButton("生物一班"); JButton mechone = new JButton("机械一班"); JButton mechtwo = new JButton("机械二班"); JButton mechthree = new JButton("机械三班"); JLabel title = new JLabel("学生信息系统主界面"); JLabel banket1 = new JLabel(); JLabel banket2 = new JLabel(); GridBagLayout lay = new GridBagLayout(); setLayout(lay); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.NONE; constraints.anchor = GridBagConstraints.EAST; constraints.weightx = 2; constraints.weighty = 5; JPanel jp = new JPanel(); jp.setLayout(new GridLayout(1, 3)); jp.add(banket1); jp.add(title); jp.add(banket2); studentframe.add(jp, BorderLayout.NORTH); add(computerone, constraints, 0, 1, 1, 1); add(computertwo, constraints, 0, 2, 1, 1); add(computerthree, constraints, 0, 3, 1, 1); add(bioone, constraints, 0, 4, 1, 1); add(mechone, constraints, 1, 1, 1, 1); add(mechtwo , constraints, 1, 2, 1, 1); add(mechthree , constraints, 1, 3, 1, 1); computerone.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent Event){ String sq1 = "select * from studentinfo where class = '一班' and major = '计算机'"; studentinfo info = new studentinfo("计算机一班学生信息系统", sql); } }); computertwo.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent Event){ String sq1 = "select * from studentinfo where class = '二班' and major = '计算机'"; studentinfo info = new studentinfo("计算机二班学生信息系统", sql); } }); computerthree.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent Event){ String sq1 = "select * from studentinfo where class = '三班' and major = '计算机'"; studentinfo info = new studentinfo("计算机三班学生信息系统", sql); } }); bioone.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent Event){ String sq1 = "select * from studentinfo where class = '一班' and major = '生物系'"; studentinfo info = new studentinfo("生物一班学生信息系统", sql); } }); mechone.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent Event){ String sq1 = "select * from studentinfo where class = '一班' and major = '机械'"; studentinfo info = new studentinfo("机械一班学生信息系统", sql); } }); mechtwo.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent Event){ String sq1 = "select * from studentinfo where class = '二班' and major = '机械'"; studentinfo info = new studentinfo("机械二班学生信息系统", sql); } }); mechthree.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent Event){ String sq1 = "select * from studentinfo where class = '三班' and major = '机械'"; studentinfo info = new studentinfo("机械三班学生信息系统", sql); } }); }
}
阅读全文
0 0
- 界面系统运行界面03--java
- 系统界面
- 初学者dos界面编译运行Java程序
- 系统管理主菜单运行界面02--java
- sublime编译运行java,有dos界面
- JAVA 反射 判断操作系统 更新系统界面
- 系统登录界面代码实现--Java
- 隐藏运行程序界面
- 界面
- 界面
- 界面
- 界面
- 界面
- 界面
- 界面
- 界面
- 界面
- java模拟电梯运行简单实现,swing界面
- spring注解基于Annotation的依赖注入配置笔记
- python爬虫搜狐新闻
- javascript 分页插件
- 日本穷游攻略(2、行程篇)
- XAMPP启动MySQL时报端口被占用错误
- 界面系统运行界面03--java
- 了解Sql Server的执行计划
- 监听器
- 47. Permutations II
- 第三章 授权(一)访问控制
- MySQL知识杂记
- Vue-深入
- React Native在Ubuntu16下开发,环境安装期间遇到的问题
- vector 邻接表的建立