import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import maze.eng.manage;
import maze.eng.mapBuilderChilderOne;
import maze.eng.mapBuilderChilderTwo;
import maze.eng.mapBuilderFarther;
import maze.eng.walkControl;
public class Main extends JFrame
{
int keepGUI = 19;
int b = (keepGUI - 2) * 2 + 2;
private JLabel[][] area = new JLabel[b][b];
int xContStar;
int yContStar;
int xContEnd;
int yContEnd;
mapBuilderFarther builderKeeper;
manage theManage;
ImageIcon iconsOne = new ImageIcon(getClass().getResource("1.jpg"));
ImageIcon iconsTwo = new ImageIcon(getClass().getResource("2.jpg"));
ImageIcon iconsThr = new ImageIcon(getClass().getResource("3.jpg"));
ImageIcon iconsFou = new ImageIcon(getClass().getResource("4.jpg"));
private JMenuItem jmiOpen = new JMenuItem("新游戏");
private JMenuItem jmiClose = new JMenuItem("退出");
private JMenuItem chooseOne = new JMenuItem("简单");
private JMenuItem chooseTwo = new JMenuItem("中等");
private JMenuItem chooseThr = new JMenuItem("困难");
private JMenuItem chooseFou = new JMenuItem("模式1");
private JMenuItem chooseFiv = new JMenuItem("模式2");
public Main(String title)
{
super(title);
xContStar = 0;
yContStar = 0;
xContEnd = 0;
yContEnd = 0;
builderKeeper = new mapBuilderChilderOne();
final walkControl control = new walkControl();
JMenu JmenuOne = new JMenu("开始");
JmenuOne.add(jmiOpen);
JmenuOne.add(jmiClose);
JMenu JmenuTwo = new JMenu("难度");
JmenuTwo.add(chooseOne);
JmenuTwo.add(chooseTwo);
JmenuTwo.add(chooseThr);
JmenuTwo.add(chooseFou);
JmenuTwo.add(chooseFiv);
JMenuBar jmenuBar = new JMenuBar();
jmenuBar.add(JmenuOne);
jmenuBar.add(JmenuTwo);
theManage = builderKeeper.getMap(b);
final JPanel contentPane = new JPanel();
contentPane.setLayout(new GridLayout(keepGUI,keepGUI));
final JPanel contentButton = new JPanel();
contentButton.setLayout(new BorderLayout());
contentButton.add(jmenuBar,BorderLayout.WEST);
Container contentPaneAll = getContentPane();
int count = 0;
contentPaneAll.add(contentPane, BorderLayout.CENTER);
contentPaneAll.add(contentButton, BorderLayout.NORTH);
addKeyListener(new KeyAdapter()
{
public void keyPressed(KeyEvent ev)
{
int key = ev.getKeyCode();
control.walkCont(key, theManage);
printWhe();
int cI = 0;
int cJ = 0;
for(int i = xContStar; i < xContEnd; i++)
{
cJ = 0;
for(int j = yContStar; j < yContEnd; j++)
{
if(theManage.getManage(i + 1, j + 1) == '1')
{
area[cI][cJ].setIcon(iconsOne);
}
else if(theManage.getManage(i + 1, j + 1) == '2')
{
area[cI][cJ].setIcon(iconsTwo);
}
else if(theManage.getManage(i + 1, j + 1) == '3')
{
area[cI][cJ].setIcon(iconsThr);
}
else if(theManage.getManage(i + 1, j + 1) == '4')
{
area[cI][cJ].setIcon(iconsFou);
}
cJ++;
}
cI++;
}
}
});
chooseOne.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
b = keepGUI;
theManage = builderKeeper.getMap(b);
xContStar = 0;
yContStar = 0;
xContEnd = 0;
yContEnd = 0;
for(int i = 0; i < keepGUI; i++)
{
for(int j = 0; j < keepGUI; j++)
{
if(theManage.getManage(i + 1, j + 1) == '1')
{
area[i][j].setIcon(iconsOne);
}
else if(theManage.getManage(i + 1, j + 1) == '2')
{
area[i][j].setIcon(iconsTwo);
}
else if(theManage.getManage(i + 1, j + 1) == '3')
{
area[i][j].setIcon(iconsThr);
}
else if(theManage.getManage(i + 1, j + 1) == '4')
{
area[i][j].setIcon(iconsFou);
}
}
}
}
});
chooseTwo.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
b = (keepGUI - 2) * 2 + 2;
theManage = builderKeeper.getMap(b);
xContStar = 0;
yContStar = 0;
xContEnd = 0;
yContEnd = 0;
for(int i = 0; i < keepGUI; i++)
{
for(int j = 0; j < keepGUI; j++)
{
if(theManage.getManage(i + 1, j + 1) == '1')
{
area[i][j].setIcon(iconsOne);
}
else if(theManage.getManage(i + 1, j + 1) == '2')
{
area[i][j].setIcon(iconsTwo);
}
else if(theManage.getManage(i + 1, j + 1) == '3')
{
area[i][j].setIcon(iconsThr);
}
else if(theManage.getManage(i + 1, j + 1) == '4')
{
area[i][j].setIcon(iconsFou);
}
}
}
}
});
chooseThr.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
b = (keepGUI - 2) * 6 + 2;
theManage = builderKeeper.getMap(b);
xContStar = 0;
yContStar = 0;
xContEnd = 0;
yContEnd = 0;
for(int i = 0; i < keepGUI; i++)
{
for(int j = 0; j < keepGUI; j++)
{
if(theManage.getManage(i + 1, j + 1) == '1')
{
area[i][j].setIcon(iconsOne);
}
else if(theManage.getManage(i + 1, j + 1) == '2')
{
area[i][j].setIcon(iconsTwo);
}
else if(theManage.getManage(i + 1, j + 1) == '3')
{
area[i][j].setIcon(iconsThr);
}
else if(theManage.getManage(i + 1, j + 1) == '4')
{
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
我做的JAVA迷宫。有很多功能的 (149个子文件)
SearchPath3.class 4KB
SearchPath3.class 4KB
SearchPath3.class 4KB
SearchPath3.class 4KB
SearchPath3.class 4KB
Sort.class 3KB
Sort.class 3KB
Main.class 2KB
HW01.class 2KB
HW01.class 2KB
Main.class 2KB
Main.class 1KB
zouMiGong.class 1KB
Maxe.class 1KB
Maxe.class 1KB
max.class 1KB
Main.class 515B
Main.class 515B
Main.class 515B
zhao.class 515B
Sort.java 4KB
Sort.java 4KB
SearchPath3.java 4KB
SearchPath3.java 3KB
SearchPath3.java 3KB
SearchPath3.java 3KB
SearchPath3.java 3KB
Main.java 3KB
Main.java 3KB
HW01.java 3KB
HW01.java 3KB
Main.java 3KB
zouMiGong.java 1KB
Maxe.java 1KB
Maxe.java 1KB
max.java 1KB
Main.java 391B
Main.java 391B
Main.java 391B
zhao.java 291B
manifest.mf 85B
manifest.mf 85B
manifest.mf 85B
manifest.mf 85B
manifest.mf 85B
manifest.mf 85B
manifest.mf 85B
manifest.mf 85B
manifest.mf 85B
manifest.mf 85B
.netbeans_automatic_build 0B
.netbeans_automatic_build 0B
.netbeans_automatic_build 0B
.netbeans_automatic_build 0B
.netbeans_automatic_build 0B
.netbeans_automatic_build 0B
.netbeans_automatic_build 0B
.netbeans_automatic_build 0B
.netbeans_automatic_build 0B
.netbeans_automatic_build 0B
project.properties 2KB
project.properties 2KB
project.properties 2KB
project.properties 2KB
project.properties 2KB
project.properties 2KB
project.properties 2KB
project.properties 2KB
project.properties 2KB
project.properties 2KB
genfiles.properties 475B
genfiles.properties 475B
genfiles.properties 475B
genfiles.properties 475B
genfiles.properties 475B
genfiles.properties 475B
genfiles.properties 475B
genfiles.properties 475B
genfiles.properties 475B
genfiles.properties 475B
private.properties 253B
private.properties 253B
private.properties 253B
private.properties 253B
private.properties 253B
private.properties 253B
private.properties 253B
private.properties 253B
private.properties 253B
private.properties 253B
迷宫main函数.txt 14KB
迷宫问题1.txt 7KB
迷3.txt 7KB
迷宫.txt 7KB
迷4.txt 5KB
生成迷宫.txt 4KB
迷宫HTML.txt 4KB
迷宫3.txt 4KB
迷宫3.txt 4KB
迷宫5.txt 4KB
共 149 条
- 1
- 2
资源评论
- yaoyaohaohaizi2014-08-31也许是因为我是小才把,反正我是运行不了,谢谢分梦想
qingtianJAVA
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功