当前位置: 首页 > news >正文

连连看的连线怎么写java_求助 这个连连看的方法地方该怎么写

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

package UI;

import java.awt.BorderLayout;

import java.awt.Color;

import java.awt.FlowLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.io.IOException;

import javax.sound.midi.InvalidMidiDataException;

import javax.sound.midi.MidiUnavailableException;

import javax.swing.*;

import javax.swing.table.DefaultTableModel;

//这个是主界面的

public class Jiemian extends JFrame {

JButton 设置按钮;

JButton 帮助按钮;

JButton 关于按钮;

JButton 开始按钮;

JButton 刷新按钮;

JButton 提示按钮;

JButton 炸弹按钮;

JButton 演示按钮;

JLabel 界面标签;

public Jiemian(){

//设置窗体***********************************************

this.setTitle("连连看");

this.setSize(830,500);

this.setLocationRelativeTo(null);

this.setLayout(null);

this.setResizable(false);

this.getContentPane().setBackground(Color.lightGray);//

wj();

this.setVisible(true);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//监听****************************************************

设置按钮.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

try {

new Shezhi();

} catch (InvalidMidiDataException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

} catch (IOException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

} catch (MidiUnavailableException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

}

}

});

帮助按钮.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

new Bangzhu();

}

});

关于按钮.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

new Guanyu();

}

});

开始按钮.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

dispose();

new Startgame();

}

});

//****************************************************

}

public void wj()

{

设置按钮=new JButton();

this.getContentPane().add(设置按钮);

设置按钮.setBounds(0, 10, 87,30);

帮助按钮=new JButton();

this.getContentPane().add(帮助按钮);

帮助按钮.setBounds(90, 10, 87,30);

关于按钮=new JButton();

this.getContentPane().add(关于按钮);

关于按钮.setBounds(180, 10, 87,30);

开始按钮=new JButton();

this.getContentPane().add(开始按钮);

开始按钮.setBounds(665, 50, 156,48);

刷新按钮=new JButton();

this.getContentPane().add(刷新按钮);

刷新按钮.setBounds(665, 130, 156,48);

提示按钮=new JButton();

this.getContentPane().add(提示按钮);

提示按钮.setBounds(665, 220, 156,48);

炸弹按钮=new JButton();

this.getContentPane().add(炸弹按钮);

炸弹按钮.setBounds(665, 310, 156,48);

演示按钮=new JButton();

this.getContentPane().add(演示按钮);

演示按钮.setBounds(665, 400, 156,48);

界面标签=new JLabel();

this.getContentPane().add(界面标签);

界面标签.setBounds(0, 45, 655,423);

界面标签.setBorder(BorderFactory.createLineBorder(Color.blue));

Icon imgshezhi = new ImageIcon(ClassLoader.getSystemResource("images/setup.gif"));

设置按钮.setIcon(imgshezhi);

Icon imgbangzhu = new ImageIcon(ClassLoader.getSystemResource("images/help.gif"));

帮助按钮.setIcon(imgbangzhu);

Icon imgguanyu = new ImageIcon(ClassLoader.getSystemResource("images/about.gif"));

关于按钮.setIcon(imgguanyu);

Icon kaishi = new ImageIcon(ClassLoader.getSystemResource("images/start.gif"));

开始按钮.setIcon(kaishi);

Icon shuaxin = new ImageIcon(ClassLoader.getSystemResource("images/refresh.gif"));

刷新按钮.setIcon(shuaxin);

Icon tishi = new ImageIcon(ClassLoader.getSystemResource("images/hint.gif"));

提示按钮.setIcon(tishi);

Icon zhadan = new ImageIcon(ClassLoader.getSystemResource("images/bomb.gif"));

炸弹按钮.setIcon(zhadan);

Icon yanshi = new ImageIcon(ClassLoader.getSystemResource("images/demo.gif"));

演示按钮.setIcon(yanshi);

}

public static void main(String args []){

new Jiemian();

}

}

//这个是点开始游戏按钮后的

package UI;

import java.awt.Color;

import java.awt.Window;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.BorderFactory;

import javax.swing.Icon;

import javax.swing.ImageIcon;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JOptionPane;

import javax.swing.JPanel;

public class Startgame extends JFrame {

JButton a;

int index;

JButton wj[][] = new JButton[9][11];//游戏按钮数组

int w [][] = new int [9][11];

public Startgame()

{

Jiemian jm = new Jiemian();

jm.界面标签=new JLabel();

jm.getContentPane().add(jm.界面标签);

jm.界面标签.setBounds(1, 47, 650,418);

jm.界面标签.setBorder(BorderFactory.createLineBorder(Color.yellow));

for(int i=0;i<9;i++)

{

for(int j=0;j<11;j++)

{

wj[i][j]=new JButton();

jm.getContentPane().add(wj[i][j]);

wj[i][j].setBounds(j*50+60,i*45+50,31,34);

}

}

//声明图片**********************************************

for(int i=0;i<9;i++)

{

for(int j=0;j<11;j++)

{

final int randoms=(int)(Math.random()*25+1); //产生随机数

Icon imga = new ImageIcon(ClassLoader.getSystemResource("images/"+(randoms)+".gif"));

wj[i][j].setIcon(imga);

wj[i][j].setName(randoms+"");

//***************************************************

wj[i][j].addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

JButton jb = (JButton)e.getSource();

String n = jb.getName();

System.out.println(n);

bijiao(Integer.parseInt(n));

}

});

}

}

}

public void bijiao(int f)

{

for(int i=0;i<9;i++)

{

for(int j=0;j<11;j++)

{

if(wj[i][j].getName().equals(f+""))

{

wj[i][j].setVisible(false);

}

}

}

}

public static void main(String [] args)

{

new Startgame();

}

}

求助 这个Startgame 我该怎么写这个游戏的方法

相关文章:

  • php java字节流_php中stream(流)的用法
  • java自动雨刷系统_【图文】汽车自动雨刷的使用指南
  • php 多线程处理_PHP CURL 多线程操作代码实例
  • php定义函数打印表格内容,php 自定义函数实现将数据 以excel 表格形式导出示例...
  • nodejs与php混合,php与nodejs的加密数据互通
  • php参数特殊字符,PHP中URL中特殊字符引起的问题(+,=) 分析及解决方法
  • php 鼠标点击其他区域下拉框隐藏,jQuery除指定区域外点击任何地方隐藏DIV功能...
  • java 日期转换星期,关于JAVA的小工具(日期转周几)
  • PHP的经典程序,几款经典php分页程序(1/4)
  • java gzip加解秘,vue 基于pako.js实现gzip的压缩和解压功能
  • matlab每一行白点个数,MATLAB 简单的计算白色轮廓中像素点的个数
  • java 类共享变量,Java提供了ThreadLocal(java.lang)类,实现线程内共享变量
  • Java第三方语音包发声,JDK中的包和他们的基本功能
  • python mock数据,python学习开发mock接口
  • php syslog 514,syslog详解及配置远程发送日志和远程日志分类
  • “Material Design”设计规范在 ComponentOne For WinForm 的全新尝试!
  • 「面试题」如何实现一个圣杯布局?
  • Android 初级面试者拾遗(前台界面篇)之 Activity 和 Fragment
  • crontab执行失败的多种原因
  • gf框架之分页模块(五) - 自定义分页
  • input实现文字超出省略号功能
  • Javascript 原型链
  • jquery cookie
  • JS字符串转数字方法总结
  • Lucene解析 - 基本概念
  • Protobuf3语言指南
  • Python学习笔记 字符串拼接
  • React-Native - 收藏集 - 掘金
  • ReactNative开发常用的三方模块
  • VUE es6技巧写法(持续更新中~~~)
  • vue-loader 源码解析系列之 selector
  • Vue学习第二天
  • 分享一份非常强势的Android面试题
  • 关于Java中分层中遇到的一些问题
  • 前端攻城师
  • 实现简单的正则表达式引擎
  • 使用 QuickBI 搭建酷炫可视化分析
  • 使用API自动生成工具优化前端工作流
  • 问:在指定的JSON数据中(最外层是数组)根据指定条件拿到匹配到的结果
  • 无服务器化是企业 IT 架构的未来吗?
  • Nginx惊现漏洞 百万网站面临“拖库”风险
  • NLPIR智能语义技术让大数据挖掘更简单
  • 浅谈sql中的in与not in,exists与not exists的区别
  • #AngularJS#$sce.trustAsResourceUrl
  • (3)(3.2) MAVLink2数据包签名(安全)
  • (C#)Windows Shell 外壳编程系列9 - QueryInfo 扩展提示
  • (LNMP) How To Install Linux, nginx, MySQL, PHP
  • (二)Linux——Linux常用指令
  • (分享)自己整理的一些简单awk实用语句
  • (黑马C++)L06 重载与继承
  • (机器学习的矩阵)(向量、矩阵与多元线性回归)
  • (六)激光线扫描-三维重建
  • (算法)前K大的和
  • (一)基于IDEA的JAVA基础1
  • (一)基于IDEA的JAVA基础10