001 package viewguitest;
002 import java.awt.Container;
003 import java.awt.event.ActionEvent;
004 import java.awt.event.ActionListener;
005 import java.util.ArrayList;
006
007 import javax.swing.JFrame;
008 import javax.swing.JPanel;
009
010 import antichess.ChessBoard;
011 import antichess.viewgui.ChessBoardView;
012 import antichess.viewgui.ImageMap;
013
014 /**
015 * BoardViewTest creates a game a chess with the starting locations
016 * and attempts to render it. This was primarily used during development
017 * to aid in debugging.
018 * @author nlharr
019 *
020 *
021 *
022 */
023
024 public class BoardViewTest implements ActionListener {
025
026
027
028 /**
029 * @return the content plane for the GUI
030 */
031
032 private ChessBoardView boardView;
033 private ChessBoard board;
034 public Container getContentPane(){
035 board = new ChessBoard();
036 board.newGame();
037
038
039 ArrayList<String> chessNameList = new ArrayList<String>();
040 chessNameList.add("RAntiking");
041 chessNameList.add("RBishop");
042 chessNameList.add("RKing");
043 chessNameList.add("RKnight");
044 chessNameList.add("RPawn");
045 chessNameList.add("RQueen");
046 chessNameList.add("RRook");
047 chessNameList.add("WAntiking");
048 chessNameList.add("WBishop");
049 chessNameList.add("WKing");
050 chessNameList.add("WKnight");
051 chessNameList.add("WPawn");
052 chessNameList.add("WQueen");
053 chessNameList.add("WRook");
054 chessNameList.add("board");
055 ImageMap chessMap = new ImageMap("..\\viewguitest\\imagetestfolder");
056 chessMap.loadImageList(chessNameList);
057
058 boardView = new ChessBoardView(board, chessMap, 50, 50, 400, 400);
059
060 JPanel pan = new JPanel();
061 pan.add(boardView);
062 return pan;
063 }
064
065
066 /**
067 * Handles events for the TimerLabelTest
068 */
069 public void actionPerformed(ActionEvent e) {
070
071 }
072
073
074 /**
075 * Create the GUI and shows it.
076 */
077
078 public static void createAndShowGUI() {
079 //Create and set up the window
080 JFrame.setDefaultLookAndFeelDecorated(true);
081 JFrame frame = new JFrame("AntiChessBoardViewTest");
082 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
083
084 //Create and set up the content pane and menu bar
085 BoardViewTest gui = new BoardViewTest();
086 frame.setContentPane(gui.getContentPane());
087 //Display the window
088 frame.setSize(600, 600);
089 frame.setVisible(true);
090 }
091
092 //used in testing
093 public static void main(String args[]){
094
095 javax.swing.SwingUtilities.invokeLater(new Runnable() {
096 public void run() {
097 createAndShowGUI();
098 }
099 });
100 }
101
102 }