自编的java简易飞行棋
自的编编java编编编编易行棋 棋:编编
棋子:
玩家 编编程序:
package 编编编编易行棋; import java.awt.EventQueue;
import java.awt.event.ActionEvent;import
java.awt.event.ActionListener;import javax.swing.ImageIcon;import javax.swing.JFrame;
import javax.swing.JLabel; import javax.swing.JButton;
import javax.swing.JOptionPane;public class game1 extends JFrame implements Runnable {
private static final long serialVersionUID = 8752899717443325480L;
private JLabel[] myQizi; private JLabel[] comQizi; private ImageIcon qizi; private ImageIcon qizi2; private int a = 100; private int playermy; private int playercom; private int c = 0; private int x = 0; private int m = 0; private int d; /**
* Launch the application *
* @param args */
public static void main(String args[]) { EventQueue.invokeLater(new Runnable() { public void run() { try {
game1 frame = new game1(); frame.setVisible(true); new Thread(frame).start(); } catch (Exception e) {
e.printStackTrace(); } } }); }
public game1() { super();
setResizable(false); // 禁止整窗体大小编编编编编编 getContentPane().setLayout(null);
setTitle(\人机行棋编编编\编编编置窗体 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ImageIcon map = new ImageIcon(getClass().getResource(\地编.png\qizi = new ImageIcon(getClass().getResource(\棋子.png\qizi2 = new ImageIcon(getClass().getResource(\棋子2.png\myQizi = new JLabel[26]; comQizi = new JLabel[26]; for (int i = 0; i < 26; i++) { myQizi[i] = new JLabel(); comQizi[i] = new JLabel();
myQizi[i].setSize(qizi.getIconWidth(), qizi.getIconHeight()); comQizi[i].setSize(qizi2.getIconWidth(), qizi2.getIconHeight()); getContentPane().add(myQizi[i]); getContentPane().add(comQizi[i]); }