Added tools menu in MenuBar with FEN export menu item
This commit is contained in:
parent
dc67b624ce
commit
dec0dc08ad
@ -1,5 +1,8 @@
|
||||
package dev.kske.chess.ui;
|
||||
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
@ -27,6 +30,7 @@ public class MenuBar extends JMenuBar {
|
||||
|
||||
initGameMenu();
|
||||
initEngineMenu();
|
||||
initToolsMenu();
|
||||
}
|
||||
|
||||
private void initGameMenu() {
|
||||
@ -92,6 +96,18 @@ public class MenuBar extends JMenuBar {
|
||||
add(engineMenu);
|
||||
}
|
||||
|
||||
private void initToolsMenu() {
|
||||
JMenu toolsMenu = new JMenu("Tools");
|
||||
|
||||
JMenuItem exportFENMenuItem = new JMenuItem("Export board to FEN");
|
||||
exportFENMenuItem.addActionListener((evt) -> Toolkit.getDefaultToolkit()
|
||||
.getSystemClipboard()
|
||||
.setContents(new StringSelection(mainWindow.getGame().getBoard().toFEN()), null));
|
||||
toolsMenu.add(exportFENMenuItem);
|
||||
|
||||
add(toolsMenu);
|
||||
}
|
||||
|
||||
private void startGame(Game game) {
|
||||
mainWindow.setGame(game);
|
||||
|
||||
|
Reference in New Issue
Block a user