Added tools menu in MenuBar with FEN export menu item

This commit is contained in:
Kai S. K. Engelbart 2019-07-24 07:41:45 +02:00
parent dc67b624ce
commit dec0dc08ad
Signed by: kske
GPG Key ID: 8BEB13EC5DF7EF13

View File

@ -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);