package gui;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import java.awt.Label;
import javax.swing.JSeparator;
import javax.swing.AbstractAction;
import java.awt.event.ActionEvent;
import javax.swing.Action;
import java.awt.event.ActionListener;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;
import logic.Logic;
import mchezaji.Mchezaji_Kaskazini;
import mchezaji.Mchezaji_Kusini;
import bao.Mchezo;
public class BaoBoard implements TableModelListener {
private JFrame frame;
private final Action action = new SwingAction();
private BaoTables BaoTables = new BaoTables(this);
Mchezaji_Kusini South = new Mchezaji_Kusini("Player 2");
Mchezaji_Kaskazini North = new Mchezaji_Kaskazini("Player 1");
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
BaoBoard window = new BaoBoard();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public BaoBoard() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 807, 694);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JMenuBar menuBar = new JMenuBar();
frame.setJMenuBar(menuBar);
JMenu mnNewMenu = new JMenu("File");
menuBar.add(mnNewMenu);
JMenuItem mntmNewGame = new JMenuItem("New Game");
mntmNewGame.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Mchezo game = new Mchezo();
Logic.rungame(North,South,game);
}
});
mnNewMenu.add(mntmNewGame);
JMenuItem mntmExit = new JMenuItem("Exit");
mntmExit.setAction(action);
mnNewMenu.add(mntmExit);
JMenu mnEdit = new JMenu("Edit");
menuBar.add(mnEdit);
JMenuItem mntmConfigurations = new JMenuItem("Configurations");
mnEdit.add(mntmConfigurations);
frame.getContentPane().setLayout(null);
//createTable();
frame.getContentPane().add(BaoTables.getNortTable());
frame.getContentPane().add(BaoTables.getSouthTable());
JSeparator separator = new JSeparator();
separator.setBounds(0, 330, 788, 10);
frame.getContentPane().add(separator);
Label label = new Label("b8");
label.setBounds(30, 180, 24, 21);
frame.getContentPane().add(label);
Label label_1 = new Label("b7");
label_1.setBounds(130, 180, 24, 21);
frame.getContentPane().add(label_1);
Label label_2 = new Label("b6");
label_2.setBounds(230, 180, 24, 21);
frame.getContentPane().add(label_2);
Label label_3 = new Label("b5");
label_3.setBounds(330, 180, 24, 21);
frame.getContentPane().add(label_3);
Label label_4 = new Label("b4");
label_4.setBounds(430, 180, 24, 21);
frame.getContentPane().add(label_4);
Label label_5 = new Label("b3");
label_5.setBounds(530, 180, 24, 21);
frame.getContentPane().add(label_5);
Label label_6 = new Label("b2");
label_6.setBounds(630, 180, 24, 21);
frame.getContentPane().add(label_6);
Label label_7 = new Label("b1");
label_7.setBounds(730, 180, 24, 21);
frame.getContentPane().add(label_7);
Label label_8 = new Label("a8");
label_8.setBounds(30, 290, 24, 21);
frame.getContentPane().add(label_8);
Label label_9 = new Label("a7");
label_9.setBounds(130, 290, 24, 21);
frame.getContentPane().add(label_9);
Label label_10 = new Label("a6");
label_10.setBounds(230, 290, 24, 21);
frame.getContentPane().add(label_10);
Label label_11 = new Label("a5");
label_11.setBounds(330, 290, 24, 21);
frame.getContentPane().add(label_11);
Label label_12 = new Label("a4");
label_12.setBounds(419, 290, 24, 21);
frame.getContentPane().add(label_12);
Label label_13 = new Label("a3");
label_13.setBounds(504, 290, 24, 21);
frame.getContentPane().add(label_13);
Label label_14 = new Label("a2");
label_14.setBounds(630, 290, 24, 21);
frame.getContentPane().add(label_14);
Label label_15 = new Label("a1");
label_15.setBounds(730, 290, 24, 21);
frame.getContentPane().add(label_15);
Label label_16 = new Label("A1");
label_16.setBounds(30, 345, 24, 21);
frame.getContentPane().add(label_16);
Label label_17 = new Label("A2");
label_17.setBounds(130, 345, 24, 21);
frame.getContentPane().add(label_17);
Label label_18 = new Label("A3");
label_18.setBounds(230, 345, 24, 21);
frame.getContentPane().add(label_18);
Label label_19 = new Label("A4");
label_19.setBounds(330, 345, 24, 21);
frame.getContentPane().add(label_19);
Label label_20 = new Label("A5");
label_20.setBounds(430, 345, 24, 21);
frame.getContentPane().add(label_20);
Label label_21 = new Label("A6");
label_21.setBounds(530, 345, 24, 21);
frame.getContentPane().add(label_21);
Label label_22 = new Label("A7");
label_22.setBounds(630, 345, 24, 21);
frame.getContentPane().add(label_22);
Label label_23 = new Label("A8");
label_23.setBounds(730, 345, 24, 21);
frame.getContentPane().add(label_23);
Label label_24 = new Label("B1");
label_24.setBounds(20, 463, 24, 21);
frame.getContentPane().add(label_24);
Label label_25 = new Label("B2");
label_25.setBounds(130, 463, 24, 21);
frame.getContentPane().add(label_25);
Label label_26 = new Label("B3");
label_26.setBounds(230, 473, 24, 21);
frame.getContentPane().add(label_26);
Label label_27 = new Label("B4");
label_27.setBounds(330, 463, 24, 21);
frame.getContentPane().add(label_27);
Label label_28 = new Label("B5");
label_28.setBounds(430, 463, 24, 21);
frame.getContentPane().add(label_28);
Label label_29 = new Label("B6");
label_29.setBounds(530, 473, 24, 21);
frame.getContentPane().add(label_29);
Label label_30 = new Label("B7");
label_30.setBounds(645, 473, 24, 21);
frame.getContentPane().add(label_30);
Label label_31 = new Label("B8");
label_31.setBounds(730, 473, 24, 21);
frame.getContentPane().add(label_31);
JLabel lblNewLabel = new JLabel("Name of Player North: "+North.getName());
lblNewLabel.setBounds(0, 100, 332, 15);
frame.getContentPane().add(lblNewLabel);
JLabel lblNameOfPlayer = new JLabel("Name of Player South: "+South.getName());
lblNameOfPlayer.setBounds(0, 500, 332, 15);
frame.getContentPane().add(lblNameOfPlayer);
JLabel lblPool = new JLabel("Pool of "+South.getName()+": "+South.getPool());
lblPool.setBounds(0, 520, 332, 15);
frame.getContentPane().add(lblPool);
JLabel lblPoolOfPlayer = new JLabel("Pool of "+North.getName()+": "+North.getPool());
lblPoolOfPlayer.setBounds(0, 120, 332, 15);
frame.getContentPane().add(lblPoolOfPlayer);
JButton button = new JButton("<");
button.setBounds(0, 206, 44, 22);
frame.getContentPane().add(button);
JButton btnNewButton = new JButton(">");
btnNewButton.setBounds(44, 206, 44, 22);
frame.getContentPane().add(btnNewButton);
JButton button_1 = new JButton("<");
button_1.setBounds(100, 206, 44, 22);
frame.getContentPane().add(button_1);
JButton button_2 = new JButton(">");
button_2.setBounds(144, 206, 44, 22);
frame.getContentPane().add(button_2);
JButton button_3 = new JButton("<");
button_3.setBounds(200, 206, 44, 22);
frame.getContentPane().add(button_3);
JButton button_4 = new JButton(">");
button_4.setBounds(244, 206, 44, 22);
frame.getContentPane().add(button_4);
JButton button_5 = new JButton("<");
button_5.setBounds(300, 206, 44, 22);
frame.getContentPane().add(button_5);
JButton button_6 = new JButton(">");
button_6.setBounds(344, 206, 44, 22);
frame.getContentPane().add(button_6);
JButton button_7 = new JButton("<");
button_7.setBounds(400, 206, 44, 22);
frame.getContentPane().add(button_7);
JButton button_8 = new JButton(">");
button_8.setBounds(444, 206, 44, 22);
frame.getContentPane().add(button_8);
JButton button_9 = new JButton("<");
button_9.setBounds(500, 206, 44, 22);
frame.getContentPane().add(button_9);
JButton button_10 = new JButton(">");
button_10.setBounds(544, 206, 44, 22);
frame.getContentPane().add(button_10);
JButton button_11 = new JButton("<");
button_11.setBounds(600, 206, 44, 22);
frame.getContentPane().add(button_11);
JButton button_12 = new JButton(">");
button_12.setBounds(644, 206, 44, 22);
frame.getContentPane().add(button_12);
JButton button_13 = new JButton("<");
button_13.setBounds(700, 206, 44, 22);
frame.getContentPane().add(button_13);
JButton button_14 = new JButton(">");
button_14.setBounds(744, 206, 44, 22);
frame.getContentPane().add(button_14);
JButton button_15 = new JButton("<");
button_15.setBounds(0, 266, 44, 22);
frame.getContentPane().add(button_15);
JButton button_16 = new JButton(">");
button_16.setBounds(44, 266, 44, 22);
frame.getContentPane().add(button_16);
JButton button_17 = new JButton("<");
button_17.setBounds(100, 266, 44, 22);
frame.getContentPane().add(button_17);
JButton button_18 = new JButton(">");
button_18.setBounds(144, 266, 44, 22);
frame.getContentPane().add(button_18);
JButton button_19 = new JButton("<");
button_19.setBounds(200, 266, 44, 22);
frame.getContentPane().add(button_19);
JButton button_20 = new JButton(">");
button_20.setBounds(244, 266, 44, 22);
frame.getContentPane().add(button_20);
JButton button_21 = new JButton("<");
button_21.setBounds(300, 266, 44, 22);
frame.getContentPane().add(button_21);
JButton button_22 = new JButton(">");
button_22.setBounds(344, 266, 44, 22);
frame.getContentPane().add(button_22);
JButton button_23 = new JButton("<");
button_23.setBounds(400, 266, 44, 22);
frame.getContentPane().add(button_23);
JButton button_24 = new JButton(">");
button_24.setBounds(444, 266, 44, 22);
frame.getContentPane().add(button_24);
JButton button_25 = new JButton("<");
button_25.setBounds(500, 266, 44, 22);
frame.getContentPane().add(button_25);
JButton button_26 = new JButton(">");
button_26.setBounds(544, 266, 44, 22);
frame.getContentPane().add(button_26);
JButton button_27 = new JButton("<");
button_27.setBounds(600, 266, 44, 22);
frame.getContentPane().add(button_27);
JButton button_28 = new JButton(">");
button_28.setBounds(644, 266, 44, 22);
frame.getContentPane().add(button_28);
JButton button_29 = new JButton("<");
button_29.setBounds(700, 266, 44, 22);
frame.getContentPane().add(button_29);
JButton button_30 = new JButton(">");
button_30.setBounds(744, 266, 44, 22);
frame.getContentPane().add(button_30);
JButton button_31 = new JButton("<");
button_31.setBounds(0, 430, 44, 22);
frame.getContentPane().add(button_31);
JButton button_32 = new JButton(">");
button_32.setBounds(44, 430, 44, 22);
frame.getContentPane().add(button_32);
JButton button_33 = new JButton("<");
button_33.setBounds(100, 430, 44, 22);
frame.getContentPane().add(button_33);
JButton button_34 = new JButton(">");
button_34.setBounds(144, 430, 44, 22);
frame.getContentPane().add(button_34);
JButton button_35 = new JButton("<");
button_35.setBounds(200, 430, 44, 22);
frame.getContentPane().add(button_35);
JButton button_36 = new JButton(">");
button_36.setBounds(244, 430, 44, 22);
frame.getContentPane().add(button_36);
JButton button_37 = new JButton("<");
button_37.setBounds(300, 430, 44, 22);
frame.getContentPane().add(button_37);
JButton button_38 = new JButton(">");
button_38.setBounds(344, 430, 44, 22);
frame.getContentPane().add(button_38);
JButton button_39 = new JButton("<");
button_39.setBounds(400, 430, 44, 22);
frame.getContentPane().add(button_39);
JButton button_40 = new JButton(">");
button_40.setBounds(444, 430, 44, 22);
frame.getContentPane().add(button_40);
JButton button_41 = new JButton("<");
button_41.setBounds(500, 430, 44, 22);
frame.getContentPane().add(button_41);
JButton button_42 = new JButton(">");
button_42.setBounds(544, 430, 44, 22);
frame.getContentPane().add(button_42);
JButton button_43 = new JButton("<");
button_43.setBounds(600, 430, 44, 22);
frame.getContentPane().add(button_43);
JButton button_44 = new JButton(">");
button_44.setBounds(644, 430, 44, 22);
frame.getContentPane().add(button_44);
JButton button_45 = new JButton("<");
button_45.setBounds(700, 370, 44, 22);
frame.getContentPane().add(button_45);
JButton button_46 = new JButton(">");
button_46.setBounds(744, 370, 44, 22);
frame.getContentPane().add(button_46);
JButton button_47 = new JButton("<");
button_47.setBounds(0, 370, 44, 22);
frame.getContentPane().add(button_47);
JButton button_48 = new JButton(">");
button_48.setBounds(44, 370, 44, 22);
frame.getContentPane().add(button_48);
JButton button_49 = new JButton("<");
button_49.setBounds(100, 370, 44, 22);
frame.getContentPane().add(button_49);
JButton button_50 = new JButton(">");
button_50.setBounds(144, 370, 44, 22);
frame.getContentPane().add(button_50);
JButton button_51 = new JButton("<");
button_51.setBounds(200, 370, 44, 22);
frame.getContentPane().add(button_51);
JButton button_52 = new JButton(">");
button_52.setBounds(244, 370, 44, 22);
frame.getContentPane().add(button_52);
JButton button_53 = new JButton("<");
button_53.setBounds(300, 370, 44, 22);
frame.getContentPane().add(button_53);
JButton button_54 = new JButton(">");
button_54.setBounds(344, 370, 44, 22);
frame.getContentPane().add(button_54);
JButton button_55 = new JButton("<");
button_55.setBounds(400, 370, 44, 22);
frame.getContentPane().add(button_55);
JButton button_56 = new JButton(">");
button_56.setBounds(444, 370, 44, 22);
frame.getContentPane().add(button_56);
JButton button_57 = new JButton("<");
button_57.setBounds(500, 370, 44, 22);
frame.getContentPane().add(button_57);
JButton button_58 = new JButton(">");
button_58.setBounds(544, 370, 44, 22);
frame.getContentPane().add(button_58);
JButton button_59 = new JButton("<");
button_59.setBounds(600, 370, 44, 22);
frame.getContentPane().add(button_59);
JButton button_60 = new JButton(">");
button_60.setBounds(644, 370, 44, 22);
frame.getContentPane().add(button_60);
JButton button_61 = new JButton("<");
button_61.setBounds(700, 370, 44, 22);
frame.getContentPane().add(button_61);
JButton button_62 = new JButton(">");
button_62.setBounds(744, 370, 44, 22);
frame.getContentPane().add(button_62);
JButton button_63 = new JButton("<");
button_63.setBounds(700, 430, 44, 22);
frame.getContentPane().add(button_63);
JButton button_64 = new JButton(">");
button_64.setBounds(744, 430, 44, 22);
frame.getContentPane().add(button_64);
}
private class SwingAction extends AbstractAction {
/**
*
*/
private static final long serialVersionUID = 1L;
public SwingAction() {
putValue(NAME, "Exit");
putValue(SHORT_DESCRIPTION, "Some short description");
}
public void actionPerformed(ActionEvent e) {
System.exit(1);
}
}
@Override
public void tableChanged(TableModelEvent e) {
//Was muss nun hier stehen damit die Tabelle korrekt aktualisiert wird?
}
}