Java版拼图游戏(基于swing编程提升版)

本文介绍了一个使用Java Swing编写的九宫格拼图游戏,游戏中的图片已经预先分割完成,未涵盖自动分割图片的算法。以下是详细代码实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

此拼图游戏是九宫格,图片是提前分割好的,未涉及自动分割图片算法。废话不说,代码如下:

package com.ctgu;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

public class PaintGame extends JFrame implements ActionListener{

	private JLabel jLabel;
	private JButton jButton1,jButton2;
	JPanel topPanel,dommPanel,centerPanel;
	JButton[][] jButtons;
	JButton[][] checkButtons;
	JLabel labelTime,labelBu;
	int num,sum,timeCount;
	boolean boo;
	private int blackrow;
	private int blackcol;
	private JButton blackButton;
	String[][] strings = new String[4][4];
	static Timer timer;
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		PaintGame pGame = new PaintGame();

		timer = new Timer(1000,pGame);
		timer.start();
		/*Thread thread = new Thread(pGame);
		thread.start();*/
		pGame.setVisible(true);
	}

	public PaintGame(){
		super();
		this.setBounds(200, 200, 360, 525);
		this.setTitle("拼图游戏");
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setResizable(false);
		initGame();
	}
	
	public void initGame(){
		num = 0;
		sum = 30;
		timeCount = 120000;
		jLabel = new JLabel();
		jButton1 = new JButton();
		jButton2 = new JButton();
		jButtons = new JButton[4][4];
		checkButtons = new JButton[4][4];
		labelTime = new JLabel();
		labelBu
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值