/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package txz;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
*
* @author 田雪峰
*/
class mainFrame extends JFrame implements ActionListener,ItemListener//主面板类
{
JLabel lb;
JLabel lb2;
JButton btnrenew,btnlast,btnnext,btnchoose,btnfirst,btnover,btnmuc,btnback;
mainpanel panel;
Sound sound;
JComboBox jc=new JComboBox();
JComboBox xg=new JComboBox();
MenuItem renew=new MenuItem(" 重新开始");
MenuItem back=new MenuItem(" 悔一步");
MenuItem last=new MenuItem(" 上一关");
MenuItem next=new MenuItem(" 下一关");
MenuItem choose=new MenuItem(" 选关");
MenuItem exit=new MenuItem(" 退出");
MenuItem qin=new MenuItem(" 琴萧合奏");
MenuItem po=new MenuItem(" 泡泡堂");
MenuItem guang=new MenuItem(" 灌篮高手");
MenuItem nor=new MenuItem(" 默认");
MenuItem eye=new MenuItem(" eyes on me");
MenuItem helper=new MenuItem(" 帮助主题");
MenuItem about=new MenuItem(" 关于推箱子...");
MenuItem x1=new MenuItem(" 1");
MenuItem x2=new MenuItem(" 2");
MenuItem x3=new MenuItem(" 3");
MenuItem x4=new MenuItem(" 4");
MenuItem x5=new MenuItem(" 5");
MenuItem x6=new MenuItem(" 6");
MenuItem x7=new MenuItem(" 7");
MenuItem x8=new MenuItem(" 8");
MenuItem x9=new MenuItem(" 9");
MenuItem x10=new MenuItem(" 10");
mainFrame()
{
super("推箱子");
setSize(720,720);
setVisible(true);
setResizable(false);
setLocation(300,20);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container cont=getContentPane();
cont.setLayout(null);
cont.setBackground(Color.black);
Menu choice=new Menu(" 选项");
choice.add(renew);choice.add(last);choice.add(next);choice.add(choose);choice.add(back);
choice.addSeparator();choice.add(exit);
renew.addActionListener(this);
last.addActionListener(this);
next.addActionListener(this);
choose.addActionListener(this);
exit.addActionListener(this);
back.addActionListener(this);
Menu setmuc=new Menu(" 设置音乐");
setmuc.add(nor);setmuc.add(qin);setmuc.add(po);setmuc.add(guang);setmuc.add(eye);
nor.addActionListener(this);
qin.addActionListener(this);
po.addActionListener(this);
guang.addActionListener(this);
eye.addActionListener(this);
Menu help=new Menu(" 帮助");
help.add(helper);help.addSeparator();help.add(about);
helper.addActionListener(this);
about.addActionListener(this);
MenuBar bar=new MenuBar();
bar.add(choice);bar.add(setmuc);bar.add(help);
setMenuBar(bar); //菜单
nor.setEnabled(false);
lb=new JLabel("JAVA推箱子",SwingConstants.CENTER);
lb2=new JLabel(" 更换音乐",SwingConstants.CENTER);
JLabel lb3=new JLabel("选关",SwingConstants.CENTER);
add(lb);add(lb2);
add(lb3);
lb.setBounds(100,20,400,20);
lb.setForeground(Color.white);
lb2.setBounds(625,300,55,20);
lb2.setForeground(Color.white);
lb3.setBounds(625,200,55,20);
lb3.setForeground(Color.white);
btnrenew=new JButton("重来");
btnback=new JButton("悔一步");
//btnlast=new JButton("上一关");
//btnnext=new JButton("下一关");
//btnchoose=new JButton("选关");
//btnfirst=new JButton("第1关");
//btnover=new JButton("最终关");
btnmuc=new JButton("音乐关");
add(btnrenew);add(btnmuc);add(btnback);
btnrenew.setBounds(625,100,80,30);
btnrenew.addActionListener(this);
btnback.setBounds(625,150,80,30);
btnback.addActionListener(this);
//btnfirst.setBounds(625,200,80,30);
//btnfirst.addActionListener(this);
//btnlast.setBounds(625,250,80,30);
//btnlast.addActionListener(this);
//btnnext.setBounds(625,300,80,30);
//btnnext.addActionListener(this);
//btnover.setBounds(625,350,80,30);
//btnover.addActionListener(this);
//btnchoose.setBounds(625,400,80,30);
//btnchoose.addActionListener(this);
btnmuc.setBounds(625,450,80,30);
btnmuc.addActionListener(this);
xg.setBounds(625,250,80,20);
xg.addItem("1");
xg.addItem("2");
xg.addItem("3");
xg.addItem("4");
xg.addItem("5");
xg.addItem("6");
xg.addItem("7");
xg.addItem("8");
xg.addItem("9");
xg.addItem("10");
xg.addItemListener(this);
cont.add(xg);
jc.setBounds(625,350,80,20);
jc.addItem("默认");
jc.addItem("琴萧合奏");
jc.addItem("泡泡堂");
jc.addItem("灌篮高手");
jc.addItem("eyes on me");
jc.addItemListener(this);
cont.add(jc);
sound=new Sound();
sound.loadSound();
panel=new mainpanel();
add(panel);
panel.play(panel.level);
panel.requestFocus();
validate();
}
//按钮事件
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==btnrenew||e.getSource()==renew)//重新开始
{
panel.play(panel.level);
panel.requestFocus();
panel.remove();
}
else if(e.getSource()==btnlast||e.getSource()==last)//上一关
{
panel.level--;
if(panel.level<1)
{panel.level++;JOptionPane.showMessageDialog(this,"本关是第一关");panel.requestFocus();}
else
{
panel.play(panel.level);
panel.requestFocus();
}
panel.remove();
}
else if(e.getSource()==btnnext||e.getSource()==next)//下一关
{
panel.level++;
if(panel.level>panel.maxlevel())
{panel.level--;JOptionPane.showMessageDialog(this,"本关已是最后一关");panel.requestFocus();}
else
{
panel.play(panel.level);
panel.requestFocus();
}
panel.remove();
}
else if(e.getSource()==exit)System.exit(0);
else if(e.getSource()==about)//关于
{
JOptionPane.showMessageDialog(this, "QQ:368000162");
}
else if(e.getSource()==btnchoose||e.getSource()==choose)//选关
{
String lel=JOptionPane.showInputDialog(this,"请输入您要转到的关卡号:(1~10)");
panel.level=Integer.parseInt(lel);
panel.remove();
if(panel.level>panel.maxlevel()||panel.level<1)
{JOptionPane.showMessageDialog(this, "没有这一关!!!");panel.requestFocus();}
else
{
panel.play(panel.level);
panel.requestFocus();
}
}
else if(e.getSource()==helper)//帮助主题
{
try {
Runtime.getRuntime().exec("c:\\windows\\hh.exe help.chm");
}
catch(Exception r){System.out.println(r);}
}
else if(e.getSource()==btnfirst)//第一关
{
panel.level=1;
panel.play(panel.level);
panel.requestFocus();
panel.remove();
}
else if(e.getSource()==btnover)//最后一关
{
panel.level=panel.maxlevel();
panel.play(panel.level);
panel.requestFocus();
panel.remove();
}
else if(e.getSource()==btnmuc)//音乐开/关
{
if(sound.isplay())
{
sound.mystop();btnmuc.setLabel("音乐开");
}
else
{
sound.loadSound();btnmuc.setLabel("音乐关");
}
panel.requestFocus();
}
else if(e.getSource()==btnback||e.getSource()==back)//悔一步
{
if(panel.isMystackEmpty())JOptionPane.showMessageDialog(this, "您还未移动!!!");
else
{
switch(panel.back())
{
case 10:panel.backup(10);break;
case 11:panel.backup(11);break;
case 20:panel.backdown(20);break;
case 21:panel.backdown(21);break;
case 30:panel.backleft(30);break;
case 31:panel.backleft(31);break;
case 40:panel.backright(40);break;
case 41:panel.backright(41);break;
}
}
panel.requestFocus();
}
else if(e.getSource()==nor)
{
jc.setSelectedIndex(0);
}
else if(e.getSource()==x1)
{
xg.setSelectedIndex(0);
}
//更换音乐
else if(e.getSource()==qin)
{
jc.setSelectedIndex(1);
}
else if(e.getSource()==guang)
{
jc.setSelectedIndex(3);
}
els
没有合适的资源?快使用搜索试试~ 我知道了~
TXZ.rar_java课设_推箱子
共101个文件
map:51个
gif:21个
class:9个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 166 浏览量
2022-09-23
09:02:07
上传
评论
收藏 241KB RAR 举报
温馨提示
基于JAVA的带音乐的普通大学计算机专业课设
资源详情
资源评论
资源推荐
收起资源包目录
TXZ.rar_java课设_推箱子 (101个子文件)
mainFrame.class 11KB
XG.class 11KB
mainpanel.class 10KB
Main.class 3KB
Readmap.class 2KB
Sound.class 2KB
Main$Buttonb1Listener.class 860B
Play.class 345B
Main$1.class 171B
3.GIF 2KB
1.GIF 2KB
4.gif 2KB
5.GIF 2KB
8.GIF 2KB
2.GIF 2KB
6.GIF 2KB
7.GIF 2KB
2.gif 1KB
0.gif 1KB
3.gif 1KB
022.gif 1KB
6.gif 1KB
9.gif 1KB
7.gif 1KB
5.gif 1KB
4.gif 1KB
8.gif 1KB
1.gif 1KB
0.gif 677B
9.GIF 512B
mainFrame.java 18KB
mainpanel.java 10KB
Main.java 2KB
Readmap.java 1KB
Sound.java 897B
Play.java 214B
Blue hills.jpg 94KB
Blue hills.jpg 28KB
39.map 440B
22.map 438B
34.map 438B
1.map 438B
44.map 438B
3.map 438B
32.map 438B
28.map 438B
38.map 438B
7.map 438B
23.map 438B
48.map 438B
19.map 438B
18.map 438B
27.map 438B
12.map 438B
26.map 438B
15.map 438B
25.map 438B
14.map 438B
5.map 438B
47.map 438B
24.map 438B
9.map 438B
2.map 438B
0.map 438B
4.map 438B
40.map 438B
29.map 438B
41.map 438B
8.map 438B
17.map 438B
11.map 438B
36.map 438B
20.map 438B
21.map 438B
31.map 438B
45.map 438B
33.map 438B
50.map 438B
42.map 438B
35.map 438B
37.map 438B
49.map 438B
43.map 438B
46.map 438B
13.map 438B
16.map 438B
10.map 438B
6.map 438B
30.map 438B
manifest.mf 85B
guang.mid 74KB
eyes on me.mid 45KB
qin.mid 44KB
nor.mid 27KB
popo.mid 15KB
project.properties 2KB
genfiles.properties 455B
private.properties 193B
build-impl.xml 32KB
build.xml 3KB
共 101 条
- 1
- 2
朱moyimi
- 粉丝: 63
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0