- 浏览: 203159 次
- 性别:
- 来自: 湖南
文章分类
最新评论
蜘蛛牌在朴克牌游戏当中是比较有趣的游戏,特别是闯关成功时刻,趣味无穷,本程序是给予窗口应用,及普通算法。
1、窗口面板控制台
2、按键加载
3、游戏执行控制过程
4、游戏基本信息
1、窗口面板控制台
package game; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; public class Araneid extends JFrame { private static final long serialVersionUID = 1L; public static final int EASY = 1; public static final int NATURAL = 2; public static final int HARD = 3; private int grade = Araneid.EASY; private Container pane = null; private PKCard cards[] = new PKCard[104]; private JLabel clickLabel = null; private int c = 0; private int n = 0; private int a = 0; private int finish = 0; Hashtable table = null; private JLabel groundLabel[] = null; public static void main(String[] args) { Araneid araneid = new Araneid(); } /** * This is the default constructor */ public Araneid() { super(); this.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE); this.setSize(1024, 742); this.setJMenuBar(new AraneidMenuBar(this)); this.pane = this.getContentPane(); this.pane.setBackground(new Color(0, 112, 26)); this.pane.setLayout(null); this.clickLabel = new JLabel(); this.clickLabel.setBounds(883, 606, 121, 96); this.pane.add(this.clickLabel); this.clickLabel.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent me) { if (c < 60) Araneid.this.deal(); } }); this.setTitle("蜘蛛牌"); this.initCards(); this.randomCards(); this.setCardsLocation(); groundLabel = new JLabel[10]; int x = 20; for (int i = 0; i < 10; i++) { groundLabel[i] = new JLabel(); groundLabel[i] .setBorder(javax.swing.BorderFactory .createEtchedBorder(javax.swing.border.EtchedBorder.RAISED)); groundLabel[i].setBounds(x, 25, 71, 96); x += 101; this.pane.add(groundLabel[i]); } this.setVisible(true); this.deal(); this.addKeyListener(new KeyAdapter() { class Show extends Thread { public void run() { Araneid.this.showEnableOperator(); } } public void keyPressed(KeyEvent e) { if (finish != 8) if (e.getKeyCode() == KeyEvent.VK_D && c < 60) { Araneid.this.deal(); } else if (e.getKeyCode() == KeyEvent.VK_M) { new Show().start(); } } }); } public void newGame() { this.randomCards(); this.setCardsLocation(); this.setGroundLabelZOrder(); this.deal(); } public int getC() { return c; } public void setGrade(int grade) { this.grade = grade; } public void initCards() { if (cards[0] != null) { for (int i = 0; i < 104; i++) { pane.remove(cards[i]); } } int n = 0; if (this.grade == Araneid.EASY) { n = 1; } else if (this.grade == Araneid.NATURAL) { n = 2; } else { n = 4; } for (int i = 1; i <= 8; i++) { for (int j = 1; j <= 13; j++) { cards[(i - 1) * 13 + j - 1] = new PKCard((i % n + 1) + "-" + j, this); } } this.randomCards(); } public void randomCards() { PKCard temp = null; for (int i = 0; i < 52; i++) { int a = (int) (Math.random() * 104); int b = (int) (Math.random() * 104); temp = cards[a]; cards[a] = cards[b]; cards[b] = temp; } } public void setNA() { a = 0; n = 0; } public void setCardsLocation() { table = new Hashtable(); c = 0; finish = 0; n = 0; a = 0; int x = 883; int y = 580; for (int i = 0; i < 6; i++) { for (int j = 0; j < 10; j++) { int n = i * 10 + j; pane.add(cards[n]); cards[n].turnRear(); cards[n].moveto(new Point(x, y)); table.put(new Point(x, y), cards[n]); } x += 10; } x = 20; y = 45; for (int i = 10; i > 5; i--) { for (int j = 0; j < 10; j++) { int n = i * 10 + j; if (n >= 104) continue; pane.add(cards[n]); cards[n].turnRear(); cards[n].moveto(new Point(x, y)); table.put(new Point(x, y), cards[n]); x += 101; } x = 20; y -= 5; } } public void showEnableOperator() { int x = 0; out: while (true) { Point point = null; PKCard card = null; do { if (point != null) n++; point = this.getLastCardLocation(n); while (point == null) { point = this.getLastCardLocation(++n); if (n == 10) n = 0; x++; if (x == 10) break out; } card = (PKCard) this.table.get(point); } while (!card.isCardCanMove()); while (this.getPreviousCard(card) != null && this.getPreviousCard(card).isCardCanMove()) { card = this.getPreviousCard(card); } if (a == 10) a = 0; for (; a < 10; a++) { if (a != n) { Point p = null; PKCard c = null; do { if (p != null) a++; p = this.getLastCardLocation(a); int z = 0; while (p == null) { p = this.getLastCardLocation(++a); if (a == 10) a = 0; if (a == n) a++; z++; if (z == 10) break out; } c = (PKCard) this.table.get(p); } while (!c.isCardCanMove()); if (c.getCardValue() == card.getCardValue() + 1) { card.flashCard(card); try { Thread.sleep(800); } catch (InterruptedException e) { // TODO 自动生成 catch 块 e.printStackTrace(); } c.flashCard(c); a++; if (a == 10) n++; break out; } } } n++; if (n == 10) n = 0; x++; if (x == 10) break out; } } public void deal() { this.setNA(); for (int i = 0; i < 10; i++) { if (this.getLastCardLocation(i) == null) { JOptionPane.showMessageDialog(this, "有空位不能发牌!", "提示", JOptionPane.WARNING_MESSAGE); return; } } int x = 20; for (int i = 0; i < 10; i++) { Point lastPoint = this.getLastCardLocation(i); if (c == 0) lastPoint.y += 5; else lastPoint.y += 20; table.remove(cards[c + i].getLocation()); cards[c + i].moveto(lastPoint); table.put(new Point(lastPoint), cards[c + i]); cards[c + i].turnFront(); cards[c + i].setCanMove(true); this.pane.setComponentZOrder(cards[c + i], 1); Point point = new Point(lastPoint); if (cards[c + i].getCardValue() == 1) { int n = cards[c + i].whichColumnAvailable(point); point.y -= 240; PKCard card = (PKCard) this.table.get(point); if (card != null && card.isCardCanMove()) { this.haveFinish(n); } } x += 101; } c += 10; } public PKCard getPreviousCard(PKCard card) { Point point = new Point(card.getLocation()); point.y -= 5; card = (PKCard) table.get(point); if (card != null) return card; point.y -= 15; card = (PKCard) table.get(point); return card; } public PKCard getNextCard(PKCard card) { Point point = new Point(card.getLocation()); point.y += 5; card = (PKCard) table.get(point); if (card != null) return card; point.y += 15; card = (PKCard) table.get(point); return card; } public Point getLastCardLocation(int column) { Point point = new Point(20 + column * 101, 25); PKCard card = (PKCard) this.table.get(point); if (card == null) return null; while (card != null) { point = card.getLocation(); card = this.getNextCard(card); } return point; } public Point getGroundLabelLocation(int column) { return new Point(groundLabel[column].getLocation()); } public void setGroundLabelZOrder() { for (int i = 0; i < 10; i++) { pane.setComponentZOrder(groundLabel[i], 105 + i); } } public void haveFinish(int column) { Point point = this.getLastCardLocation(column); PKCard card = (PKCard) this.table.get(point); do { this.table.remove(point); card.moveto(new Point(20 + finish * 10, 580)); pane.setComponentZOrder(card, 1); this.table.put(card.getLocation(), card); card.setCanMove(false); point = this.getLastCardLocation(column); if (point == null) card = null; else card = (PKCard) this.table.get(point); } while (card != null && card.isCardCanMove()); finish++; if (finish == 8) { JOptionPane.showMessageDialog(this, "恭喜你,过关了!", "成功", JOptionPane.PLAIN_MESSAGE); } if (card != null) { card.turnFront(); card.setCanMove(true); } } }
2、按键加载
package game; import javax.swing.JMenuBar; import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.JRadioButtonMenuItem; import javax.swing.ButtonGroup; public class AraneidMenuBar extends JMenuBar { /** * */ private static final long serialVersionUID = 1L; private Araneid main = null; private JMenu jMenu = null; private JMenu jMenu1 = null; private JMenuItem jMenuItem = null; private JMenuItem jMenuItem1 = null; private JMenuItem jMenuItem2 = null; private JRadioButtonMenuItem jRadioButtonMenuItem = null; private JRadioButtonMenuItem jRadioButtonMenuItem1 = null; private JRadioButtonMenuItem jRadioButtonMenuItem2 = null; private JMenuItem jMenuItem3 = null; private JMenuItem jMenuItem4 = null; /** * This is the default constructor */ public AraneidMenuBar(Araneid araneid) { super(); this.main = araneid; initialize(); } /** * This method initializes this * * @return void */ private void initialize() { this.add(getJMenu()); this.add(getJMenu1()); } /** * This method initializes jMenu * * @return javax.swing.JMenu */ private JMenu getJMenu() { if (jMenu == null) { jMenu = new JMenu(); jMenu.setText("游戏"); jMenu.add(getJMenuItem1()); jMenu.add(getJMenuItem2()); jMenu.add(getJMenuItem4()); jMenu.addSeparator(); jMenu.add(getJRadioButtonMenuItem()); jMenu.add(getJRadioButtonMenuItem1()); jMenu.add(getJRadioButtonMenuItem2()); jMenu.addSeparator(); jMenu.add(getJMenuItem3()); jMenu.addMenuListener(new javax.swing.event.MenuListener() { public void menuSelected(javax.swing.event.MenuEvent e) { if(main.getC() < 60) getJMenuItem2().setEnabled(true); else getJMenuItem2().setEnabled(false); } public void menuDeselected(javax.swing.event.MenuEvent e) {} public void menuCanceled(javax.swing.event.MenuEvent e) {} }); ButtonGroup group = new ButtonGroup(); group.add(getJRadioButtonMenuItem()); group.add(getJRadioButtonMenuItem1()); group.add(getJRadioButtonMenuItem2()); } return jMenu; } /** * This method initializes jMenu1 * * @return javax.swing.JMenu */ private JMenu getJMenu1() { if (jMenu1 == null) { jMenu1 = new JMenu(); jMenu1.setText("帮助"); jMenu1.add(getJMenuItem()); } return jMenu1; } /** * This method initializes jMenuItem * * @return javax.swing.JMenuItem */ private JMenuItem getJMenuItem() { if (jMenuItem == null) { jMenuItem = new JMenuItem(); jMenuItem.setText("关于"); jMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { new AboutDialog(main); } }); } return jMenuItem; } /** * This method initializes jMenuItem1 * * @return javax.swing.JMenuItem */ private JMenuItem getJMenuItem1() { if (jMenuItem1 == null) { jMenuItem1 = new JMenuItem(); jMenuItem1.setText("开局"); jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { main.newGame(); } }); } return jMenuItem1; } /** * This method initializes jMenuItem2 * * @return javax.swing.JMenuItem */ private JMenuItem getJMenuItem2() { if (jMenuItem2 == null) { jMenuItem2 = new JMenuItem(); jMenuItem2.setText("新一轮发牌"); jMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { if(main.getC() < 60) main.deal(); } }); } return jMenuItem2; } /** * This method initializes jRadioButtonMenuItem * * @return javax.swing.JRadioButtonMenuItem */ private JRadioButtonMenuItem getJRadioButtonMenuItem() { if (jRadioButtonMenuItem == null) { jRadioButtonMenuItem = new JRadioButtonMenuItem(); jRadioButtonMenuItem.setText("初级:单色"); jRadioButtonMenuItem.setSelected(true); jRadioButtonMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { main.setGrade(Araneid.EASY); main.initCards(); main.newGame(); } }); } return jRadioButtonMenuItem; } /** * This method initializes jRadioButtonMenuItem1 * * @return javax.swing.JRadioButtonMenuItem */ private JRadioButtonMenuItem getJRadioButtonMenuItem1() { if (jRadioButtonMenuItem1 == null) { jRadioButtonMenuItem1 = new JRadioButtonMenuItem(); jRadioButtonMenuItem1.setText("中级:双色"); jRadioButtonMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { main.setGrade(Araneid.NATURAL); main.initCards(); main.newGame(); } }); } return jRadioButtonMenuItem1; } /** * This method initializes jRadioButtonMenuItem2 * * @return javax.swing.JRadioButtonMenuItem */ private JRadioButtonMenuItem getJRadioButtonMenuItem2() { if (jRadioButtonMenuItem2 == null) { jRadioButtonMenuItem2 = new JRadioButtonMenuItem(); jRadioButtonMenuItem2.setText("高级:四色"); jRadioButtonMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { main.setGrade(Araneid.HARD); main.initCards(); main.newGame(); } }); } return jRadioButtonMenuItem2; } /** * This method initializes jMenuItem3 * * @return javax.swing.JMenuItem */ private JMenuItem getJMenuItem3() { if (jMenuItem3 == null) { jMenuItem3 = new JMenuItem(); jMenuItem3.setText("退出"); jMenuItem3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { main.dispose(); System.exit(0); } }); } return jMenuItem3; } /** * This method initializes jMenuItem4 * * @return javax.swing.JMenuItem */ private JMenuItem getJMenuItem4() { if (jMenuItem4 == null) { jMenuItem4 = new JMenuItem(); jMenuItem4.setText("显示可行操作"); jMenuItem4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { new Show().start(); } }); } return jMenuItem4; } class Show extends Thread { public void run() { main.showEnableOperator(); } } }
3、游戏执行控制过程
package game; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class PKCard extends JLabel implements MouseListener, MouseMotionListener { /** * */ private static final long serialVersionUID = 1L; private Point point = null; private Point initPoint = null; private int value = 0; private int type = 0; private String name = null; private Container pane = null; private Araneid main = null; private boolean canMove = false; private boolean isFront = false; private PKCard previousCard = null; /* * (非 Javadoc) * * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) */ public void mouseClicked(MouseEvent arg0) { // TODO 自动生成方法存根 } public void flashCard(PKCard card) { new Flash(card).start(); if(main.getNextCard(card) != null) card.flashCard(main.getNextCard(card)); } class Flash extends Thread { private PKCard card = null; public Flash(PKCard card) { this.card = card; } public void run() { boolean is = false; ImageIcon icon = new ImageIcon("images/white.gif"); for (int i = 0; i < 4; i++) { try { Thread.sleep(200); } catch (InterruptedException e) { // TODO 自动生成 catch 块 e.printStackTrace(); } if (is) { this.card.turnFront(); is = !is; } else { this.card.setIcon(icon); is = !is; } card.updateUI(); } } } /* * (非 Javadoc) * * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) */ public void mousePressed(MouseEvent arg0) { // TODO 自动生成方法存根 point = arg0.getPoint(); main.setNA(); this.previousCard = main.getPreviousCard(this); // System.out.println(((PKCard) arg0.getSource()).initPoint); // System.out.println(((PKCard) arg0.getSource()).getCardType()); // System.out.println(); } /* * (非 Javadoc) * * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent) */ public void mouseReleased(MouseEvent arg0) { // TODO 自动生成方法存根 Point point = ((JLabel) arg0.getSource()).getLocation(); int n = this.whichColumnAvailable(point); if (n == -1 || n == this.whichColumnAvailable(this.initPoint)) { this.setNextCardLocation(null); main.table.remove(this.getLocation()); this.setLocation(this.initPoint); main.table.put(this.initPoint, this); return; } point = main.getLastCardLocation(n); boolean isEmpty = false; PKCard card = null; if (point == null) { point = main.getGroundLabelLocation(n); isEmpty = true; } else { card = (PKCard) main.table.get(point); } if (isEmpty || (this.value + 1 == card.getCardValue())) { point.y += 40; if (isEmpty) point.y -= 20; this.setNextCardLocation(point); main.table.remove(this.getLocation()); point.y -= 20; this.setLocation(point); main.table.put(point, this); this.initPoint = point; if (this.previousCard != null) { this.previousCard.turnFront(); this.previousCard.setCanMove(true); } this.setCanMove(true); } else { this.setNextCardLocation(null); main.table.remove(this.getLocation()); this.setLocation(this.initPoint); main.table.put(this.initPoint, this); return; } point = main.getLastCardLocation(n); card = (PKCard) main.table.get(point); if (card.getCardValue() == 1) { point.y -= 240; card = (PKCard) main.table.get(point); if (card != null && card.isCardCanMove()) { main.haveFinish(n); } } } public void setNextCardLocation(Point point) { PKCard card = main.getNextCard(this); if (card != null) { if (point == null) { card.setNextCardLocation(null); main.table.remove(card.getLocation()); card.setLocation(card.initPoint); main.table.put(card.initPoint, card); } else { point = new Point(point); point.y += 20; card.setNextCardLocation(point); point.y -= 20; main.table.remove(card.getLocation()); card.setLocation(point); main.table.put(card.getLocation(), card); card.initPoint = card.getLocation(); } } } public int whichColumnAvailable(Point point) { int x = point.x; int y = point.y; int a = (x - 20) / 101; int b = (x - 20) % 101; if (a != 9) { if (b > 30 && b <= 71) a = -1; else if (b > 71) a++; } else if (b > 71) { a = -1; } if (a != -1) { Point p = main.getLastCardLocation(a); if (p == null) p = main.getGroundLabelLocation(a); b = y - p.y; if (b <= -96 || b >= 96) a = -1; } return a; } /* * (非 Javadoc) * * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent) */ public void mouseEntered(MouseEvent arg0) { // TODO 自动生成方法存根 } /* * (非 Javadoc) * * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent) */ public void mouseExited(MouseEvent arg0) { // TODO 自动生成方法存根 } /* * (非 Javadoc) * * @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent) */ public void mouseDragged(MouseEvent arg0) { // TODO 自动生成方法存根 if (canMove) { int x = 0; int y = 0; Point p = arg0.getPoint(); x = p.x - point.x; y = p.y - point.y; this.moving(x, y); } } public void moving(int x, int y) { PKCard card = main.getNextCard(this); Point p = this.getLocation(); pane.setComponentZOrder(this, 1); main.table.remove(p); p.x += x; p.y += y; this.setLocation(p); main.table.put(p, this); if (card != null) card.moving(x, y); } /* * (非 Javadoc) * * @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent) */ public void mouseMoved(MouseEvent arg0) { // TODO 自动生成方法存根 } /** * This is the default constructor */ public PKCard(String name, Araneid araneid) { super(); this.type = new Integer(name.substring(0, 1)).intValue(); this.value = new Integer(name.substring(2)).intValue(); this.name = name; this.main = araneid; this.pane = this.main.getContentPane(); this.addMouseListener(this); this.addMouseMotionListener(this); this.setIcon(new ImageIcon("images/rear.gif")); this.setSize(71, 96); this.setVisible(true); } public void turnFront() { this.setIcon(new ImageIcon("images/" + name + ".gif")); this.isFront = true; } public void turnRear() { this.setIcon(new ImageIcon("images/rear.gif")); this.isFront = false; this.canMove = false; } public void moveto(Point point) { this.setLocation(point); this.initPoint = point; } public void setCanMove(boolean can) { this.canMove = can; PKCard card = main.getPreviousCard(this); if (card != null && card.isCardFront()) { if (!can) { if (!card.isCardCanMove()) return; else card.setCanMove(can); } else { if (this.value + 1 == card.getCardValue() && this.type == card.getCardType()) { card.setCanMove(can); } else card.setCanMove(false); } } } public boolean isCardFront() { return this.isFront; } public boolean isCardCanMove() { return this.canMove; } public int getCardValue() { return value; } public int getCardType() { return type; } }
4、游戏基本信息
package game; import javax.swing.JDialog; import javax.swing.JFrame; import java.awt.Point; import javax.swing.JTabbedPane; import javax.swing.JPanel; import javax.swing.JButton; import javax.swing.JLabel; public class AboutDialog extends JDialog { private javax.swing.JPanel jContentPane = null; protected JFrame owner = null; private JTabbedPane jTabbedPane = null; private JPanel jPanel = null; private JPanel jPanel1 = null; private JPanel jPanel2 = null; private JPanel jPanel3 = null; private JPanel jPanel4 = null; private JButton jButton = null; private JLabel jLabel = null; private JLabel jLabel1 = null; private JLabel jLabel2 = null; private JLabel jLabel3 = null; /** * This is the default constructor */ public AboutDialog(JFrame frame) { super(frame); owner = frame; setResizable(false); initialize(); } /** * This method initializes this * * @return void */ private void initialize() { this.setTitle("关于对话框"); this.setSize(209, 132); this.setContentPane(getJContentPane()); this.setLocation(); this.setVisible(true); this.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { owner.setEnabled(true); AboutDialog.this.dispose(); } }); } /** * This method initializes jContentPane * * @return javax.swing.JPanel */ private javax.swing.JPanel getJContentPane() { if (jContentPane == null) { jContentPane = new javax.swing.JPanel(); jContentPane.setLayout(new java.awt.BorderLayout()); jContentPane.add(getJTabbedPane(), java.awt.BorderLayout.CENTER); jContentPane.add(getJPanel4(), java.awt.BorderLayout.SOUTH); } return jContentPane; } private void setLocation() { Point point = owner.getLocation(); int width = this.getWidth(); int height = this.getHeight(); int x = (int) (point.getX() + (owner.getWidth() - width) / 2); x = (x > 1024 - width ? 1024 - width : x); x = (x < 0 ? 0 : x); int y = (int) (point.getY() + (owner.getHeight() - height) / 2); y = (y > 768 - height ? 768 - height : y); y = (y < 0 ? 0 : y); setLocation(x, y); } /** * This method initializes jTabbedPane * * @return javax.swing.JTabbedPane */ private JTabbedPane getJTabbedPane() { if (jTabbedPane == null) { jTabbedPane = new JTabbedPane(); jTabbedPane.addTab("关于", null, getJPanel(), null); jTabbedPane.addTab("作者", null, getJPanel1(), null); jTabbedPane.addTab("班级", null, getJPanel2(), null); jTabbedPane.addTab("学号", null, getJPanel3(), null); } return jTabbedPane; } /** * This method initializes jPanel * * @return javax.swing.JPanel */ private JPanel getJPanel() { if (jPanel == null) { jLabel = new JLabel(); jPanel = new JPanel(); jLabel.setText("蜘蛛牌"); jLabel.setFont(new java.awt.Font("楷体_GB2312", java.awt.Font.BOLD, 18)); jLabel.setForeground(java.awt.Color.blue); jPanel.add(jLabel, null); } return jPanel; } /** * This method initializes jPanel1 * * @return javax.swing.JPanel */ private JPanel getJPanel1() { if (jPanel1 == null) { jLabel1 = new JLabel(); jPanel1 = new JPanel(); jLabel1.setText("XXX"); jLabel1.setFont(new java.awt.Font("楷体_GB2312", java.awt.Font.BOLD, 18)); jLabel1.setForeground(java.awt.Color.blue); jPanel1.add(jLabel1, null); } return jPanel1; } /** * This method initializes jPanel2 * * @return javax.swing.JPanel */ private JPanel getJPanel2() { if (jPanel2 == null) { jLabel2 = new JLabel(); jPanel2 = new JPanel(); jLabel2.setText("XXX计算机(XXXX)班"); jLabel2.setForeground(java.awt.Color.blue); jLabel2.setFont(new java.awt.Font("楷体_GB2312", java.awt.Font.BOLD, 18)); jPanel2.add(jLabel2, null); } return jPanel2; } /** * This method initializes jPanel3 * * @return javax.swing.JPanel */ private JPanel getJPanel3() { if (jPanel3 == null) { jLabel3 = new JLabel(); jPanel3 = new JPanel(); jLabel3.setText("020505101"); jLabel3.setForeground(java.awt.Color.blue); jLabel3.setFont(new java.awt.Font("楷体_GB2312", java.awt.Font.BOLD, 18)); jPanel3.add(jLabel3, null); } return jPanel3; } /** * This method initializes jPanel4 * * @return javax.swing.JPanel */ private JPanel getJPanel4() { if (jPanel4 == null) { jPanel4 = new JPanel(); jPanel4.add(getJButton(), null); } return jPanel4; } /** * This method initializes jButton * * @return javax.swing.JButton */ private JButton getJButton() { if (jButton == null) { jButton = new JButton(); jButton.setText("确定"); jButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { owner.setEnabled(true); AboutDialog.this.dispose(); } }); } return jButton; } } // @jve:decl-index=0:visual-constraint="10,10"
发表评论
-
java版 纸牌
2012-05-30 15:43 854java 纸牌游戏,有连翻一张或三张两种玩法,程序在部分点击区 ... -
java版 推箱子
2012-01-12 17:24 1488java版 推箱子源码 import javax.swin ... -
java 基础加强
2011-01-07 14:17 753java基础 jdk1.5 新特征 ... -
网络五子棋
2011-01-05 15:50 1040最近空限,完成之前未完成的网络五子棋,它是面向TCP协 ... -
java图片处理:文字图像水印 缩放补白
2010-12-28 11:40 1158package com.util; import j ... -
Java2D绘制五星红旗
2010-12-27 09:17 1151/** 使用Java2D绘制五星红旗 五星 ... -
网络编程
2010-12-21 14:16 1228网络编程 网络编程的基础知识 网络协议与TCP/IP 计算 ... -
IO/输入输出
2010-12-21 14:14 1428IO/输入输出 File类 它是 ... -
银行业务调度系统
2010-08-19 18:34 1323模拟实现银行业务调度系统逻辑,具体需求如下: 银行内有6 ... -
交通灯管理系统
2010-08-18 13:16 1289模拟实现十字路口的交通灯管理系统逻辑,具体需求如下: 异 ... -
贪吃蛇游戏
2010-08-17 08:32 1696对大多数人来说,要想自己编写出《贪吃蛇》游戏的程序 ... -
j2se版俄罗斯方块
2009-10-21 21:22 14541.图形界面 import java.awt.*; ... -
豆子吃妖精
2009-10-19 21:30 765本程序是运用了图形化画版和多程技术,只支持固定运行轨迹, ... -
连连看
2009-10-09 20:54 1012java不易开发大型游戏,但任一语言都有是相通,本程序运 ... -
Globle Get 多线程下载系统
2009-10-07 21:41 1084GlobalGet”是实现HTTP协议和FTP协议的多线程下载 ... -
控制台五子棋
2009-08-17 20:15 912<p>这是一个控制台的五子棋,它的妙处是它算法侦听 ...
相关推荐
jQuery蜘蛛纸牌电脑版游戏代码下载地址jQuery实现Windows扑克牌小游戏代码,使用jQuery基于CSS3制作的WINDOWS7系统电脑自动的蜘蛛纸牌游戏基于jquery实现的蜘蛛纸牌电脑版HTML5源码-Javascript...-... 2022年3月20日 ...
【蜘蛛纸牌(Java)实现】是一个典型的编程项目,它涉及到使用Java语言来构建一个桌面游戏。蜘蛛纸牌是一款流行的单人卡牌游戏,玩家的目标是通过排列卡牌顺序来清除所有卡组。在这个Java实现中,我们可以学习到以下...
标题“可在win10上运行的蜘蛛纸牌”指的是这款软件是兼容Windows 10操作系统的,用户可以在Windows 10环境下愉快地玩这款经典的蜘蛛纸牌游戏。蜘蛛纸牌是一款广受欢迎的单人纸牌游戏,源自微软在Windows操作系统中...
JavaScript蜘蛛纸牌小游戏是一款基于网页的休闲娱乐游戏,利用JavaScript编程语言实现,为用户提供了一种在浏览器上体验经典蜘蛛纸牌的方式。此游戏通常包括多种难度级别,供玩家选择,以适应不同玩家的需求和挑战性...
本教程将专注于使用Python的Pygame库来创建一个“蜘蛛纸牌”游戏。Pygame是Python的一个扩展库,专为开发2D游戏而设计,它提供了丰富的功能,包括图形绘制、音频处理、事件管理等,使得游戏开发变得相对简单。 首先...
1. 游戏规则:蜘蛛纸牌的目标是将牌堆中的所有牌按照同花色从K到A的顺序排列。游戏包含八副牌,分为十列,起始时四列露出一张牌,其余六列露出两张牌。玩家通过移动牌来逐步完成目标。 2. 用户界面:游戏界面通常...
【标题】中的“一个简易的用C语言编写的蜘蛛纸牌小游戏”表明我们要讨论的是一个使用C语言开发的蜘蛛纸牌游戏。蜘蛛纸牌是一种流行的单人纸牌游戏,通常在计算机上玩,这里它是通过编程语言C实现的。 【描述】的...
在创建蜘蛛纸牌游戏的UI时,我们需要设计一个清晰、直观的布局,展示牌堆、储备区、基础区以及列。XAML可以用来定义按钮、图像、文本框等控件,并通过布局容器(如Grid或StackPanel)来组织它们。例如,每个牌堆可能...
蜘蛛纸牌是一款单人游戏,目标是通过排列一系列牌组,使每组牌都是由同一花色的牌从K到A连续组成。这款游戏对玩家的逻辑思维和策略规划能力有较高的要求。 首先,让我们了解C++编程语言的基础。C++是一种强大的、...
2. **模型层**:这部分代码实现了蜘蛛纸牌的游戏逻辑,包括发牌、移牌、洗牌等规则,以及判断游戏是否胜利的条件。 3. **视图层**:这部分代码负责展示游戏界面,包括牌桌布局、用户交互元素(如按钮、文本框)等,...
【Java实现蜘蛛纸牌小游戏源码】是一个基于Java编程语言开发的项目,旨在复现Windows操作系统中的经典小游戏——蜘蛛纸牌。在这个项目中,开发者利用Java的面向对象特性、图形用户界面(GUI)以及事件处理机制,构建...
蜘蛛纸牌游戏的核心逻辑,如计分、游戏规则的判断等,都是由JavaScript编写。 4. ECMAScript:是JavaScript的标准,定义了语言的语法和基本对象。最新的ECMAScript版本可能会引入新的特性,如箭头函数、模板字符串等...
java实现游戏-蜘蛛纸牌(模仿Windows经典游戏) ——————————————————————————————————————— 这是一个使用java实现的简单小游戏,蜘蛛纸牌,模仿了Windows操作系统的经典游戏...
【标题】"蜘蛛纸牌源码"涉及到的是一个基于Java编程语言实现的蜘蛛纸牌游戏。蜘蛛纸牌是一款广受欢迎的单人纸牌游戏,它考验玩家的逻辑思维能力和策略规划。通过分析这个源码,我们可以深入理解Java编程的基础、面向...
JavaScript版蜘蛛纸牌是一款完全基于JavaScript编程语言实现的在线游戏,它模仿了Windows操作系统中经典的蜘蛛纸牌游戏。这款游戏的开发耗时三周,旨在提供与原版游戏类似的体验,让玩家可以在网页环境中享受蜘蛛...
3. **游戏逻辑**:蜘蛛纸牌的规则涉及到牌的排序、移除、堆叠等操作,这些都需要用到数据结构和算法。源码中可能会包含对链表、栈、队列等数据结构的运用,以及搜索、排序等算法的实现。 4. **事件驱动编程**:当...
1. **游戏规则**:蜘蛛纸牌有四个目标列,玩家需将同花色的牌从K到A依次排列。游戏涉及8副牌,分为10个牌堆,玩家需策略性地从可移动的牌堆中抽牌并移至目标列。 2. **用户界面**:源码会展示如何创建直观的图形...
在这个Java蜘蛛纸牌项目中,源代码可能是由一系列类、方法和逻辑控制结构组成的,用于实现游戏的各种功能,如洗牌、发牌、移动牌堆等。Java是一种面向对象的编程语言,它以其跨平台性和强大的库支持而受到广大开发者...
蜘蛛纸牌通常包含8副牌,分为10个列,开始时4列有5张牌面朝上,其余6列有5张牌面朝下。游戏的目标是通过移动将牌面按同花顺从K到A全部排列,每完成一套花色的序列就称为“清除”一列。游戏的关键在于策略性的移牌,...
【标题】"蜘蛛纸牌 eclipse Java" 涉及到的是使用Java编程语言在Eclipse集成开发环境中构建一个蜘蛛纸牌游戏的项目。Eclipse是一款广泛使用的开源Java IDE,为开发者提供了丰富的工具集,便于编写、调试和优化Java...