JAVA简易抽奖系统基于mysql和Swing

Swing开发抽奖系统

一个简易的抽奖系统

数据库部分采用上一次的工具类 JDBC工具类
直奔主题,上源码

package Lucky;

import java.awt.Font;
import java.sql.SQLException;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class Myframe extends JFrame {
	JPanel panel = new JPanel();
	JLabel label = new JLabel("欢迎进入抽奖系统");
	JButton button1 = new JButton("1.进行抽奖");
	JButton button2 = new JButton("2.退出系统");
	JButton button3 = new JButton("3.查询纪录");
	JButton button4 = new JButton("4.统计分析");

	public Myframe(String title) {
		super(title);
		this.setSize(270, 400);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		this.setVisible(true);
		this.setContentPane(panel);
		label.setFont(new Font("黑体", Font.BOLD, 20));
		this.add(label);

		button1.addActionListener(e -> {
			try {
				new Welcome().LuckyDraw();
			} catch (SQLException e1) {
				e1.printStackTrace();
				System.out.println("抽奖失败");
			}
		});
		button2.addActionListener(e -> {
			int select = JOptionPane.showConfirmDialog(this, "是否确认退出", "确认", JOptionPane.YES_NO_OPTION);
			if (0 == select) {
				System.out.println("退出");
				this.setVisible(false);
				this.dispose();
			}
		});
		button3.addActionListener(e -> {
			System.out.println("抽奖纪录:");
			try {
				SelectUtil.SelectMethod();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
		});
		button4.addActionListener(e -> {
			new Welcome().total();
		});

		panel.add(button1);
		panel.add(button2);
		panel.add(button3);
		panel.add(button4);
	}

	public static void main(String[] args) {
		JFrame welcomeframe = new Myframe("抽奖系统");
	}

}

界面效果:
在这里插入图片描述
运行效果:
1.按钮一 抽奖:在这里插入图片描述
2.按钮三 查询:
在这里插入图片描述
在这里插入图片描述

3.按钮四 统计:
在这里插入图片描述

4.按钮二 退出:
在这里插入图片描述

  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值