This repository has been archived on 2021-02-18. You can view files and clone it, but cannot push or open issues or pull requests.
chess/src/dev/kske/chess/ui/MainWindow.java

72 lines
1.6 KiB
Java
Raw Normal View History

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