2019-07-06 16:37:42 +02:00
|
|
|
package dev.kske.chess.ui;
|
2019-07-01 18:26:43 +02:00
|
|
|
|
|
|
|
import java.awt.BorderLayout;
|
|
|
|
import java.awt.EventQueue;
|
|
|
|
|
2019-07-03 11:05:20 +02:00
|
|
|
import javax.swing.JButton;
|
2019-07-01 18:26:43 +02:00
|
|
|
import javax.swing.JFrame;
|
2019-07-03 11:05:20 +02:00
|
|
|
import javax.swing.JPanel;
|
2019-07-01 18:26:43 +02:00
|
|
|
|
2019-07-06 18:05:00 +02:00
|
|
|
import dev.kske.chess.board.Board;
|
2019-07-06 16:37:42 +02:00
|
|
|
|
2019-07-01 18:26:43 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Project: <strong>Chess</strong><br>
|
2019-07-06 16:37:42 +02:00
|
|
|
* File: <strong>MainWindow.java</strong><br>
|
2019-07-01 18:26:43 +02:00
|
|
|
* Created: <strong>01.07.2019</strong><br>
|
|
|
|
* Author: <strong>Kai S. K. Engelbart</strong>
|
|
|
|
*/
|
2019-07-06 16:37:42 +02:00
|
|
|
public class MainWindow {
|
2019-07-01 18:26:43 +02:00
|
|
|
|
|
|
|
private JFrame mframe;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Launch the application.
|
|
|
|
*/
|
|
|
|
public static void main(String[] args) {
|
|
|
|
EventQueue.invokeLater(new Runnable() {
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
try {
|
2019-07-06 16:37:42 +02:00
|
|
|
MainWindow window = new MainWindow();
|
2019-07-01 18:26:43 +02:00
|
|
|
window.mframe.setVisible(true);
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create the application.
|
|
|
|
*/
|
2019-07-06 16:37:42 +02:00
|
|
|
public MainWindow() {
|
2019-07-01 18:26:43 +02:00
|
|
|
initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the contents of the frame.
|
|
|
|
*/
|
|
|
|
private void initialize() {
|
|
|
|
mframe = new JFrame();
|
2019-07-02 22:06:48 +02:00
|
|
|
mframe.setResizable(false);
|
2019-07-03 11:05:20 +02:00
|
|
|
mframe.setBounds(100, 100, 494, 565);
|
2019-07-01 18:26:43 +02:00
|
|
|
mframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
|
|
2019-07-01 19:37:15 +02:00
|
|
|
BoardPanel boardPanel = new BoardPanel(new Board());
|
2019-07-01 18:26:43 +02:00
|
|
|
boardPanel.setLayout(null);
|
|
|
|
mframe.getContentPane().add(boardPanel, BorderLayout.CENTER);
|
2019-07-03 11:05:20 +02:00
|
|
|
|
|
|
|
JPanel toolPanel = new JPanel();
|
|
|
|
mframe.getContentPane().add(toolPanel, BorderLayout.NORTH);
|
|
|
|
|
|
|
|
JButton btnRestart = new JButton("Restart");
|
|
|
|
btnRestart.addActionListener((evt) -> boardPanel.reset());
|
|
|
|
toolPanel.add(btnRestart);
|
2019-07-02 22:06:48 +02:00
|
|
|
mframe.pack();
|
2019-07-07 13:53:57 +02:00
|
|
|
|
|
|
|
// Display dialog for game mode selection
|
|
|
|
new GameModeDialog(boardPanel).setVisible(true);
|
2019-07-01 18:26:43 +02:00
|
|
|
}
|
|
|
|
}
|