1.1 --- a/src/de/uapcore/sudoku/MainMenu.java Fri Feb 01 10:18:47 2013 +0100 1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 @@ -1,101 +0,0 @@ 1.4 -/* 1.5 - * Copyright 2013 Mike Becker. All rights reserved. 1.6 - * 1.7 - * Redistribution and use in source and binary forms, with or without 1.8 - * modification, are permitted provided that the following conditions are met: 1.9 - * 1.10 - * 1. Redistributions of source code must retain the above copyright 1.11 - * notice, this list of conditions and the following disclaimer. 1.12 - * 1.13 - * 2. Redistributions in binary form must reproduce the above copyright 1.14 - * notice, this list of conditions and the following disclaimer in the 1.15 - * documentation and/or other materials provided with the distribution. 1.16 - * 1.17 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 1.18 - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1.19 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1.20 - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 1.21 - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 1.22 - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 1.23 - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 1.24 - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 1.25 - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 1.26 - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 1.27 - * POSSIBILITY OF SUCH DAMAGE. 1.28 - */ 1.29 - 1.30 -package de.uapcore.sudoku; 1.31 - 1.32 -import javax.swing.JMenu; 1.33 -import javax.swing.JMenuBar; 1.34 -import javax.swing.JMenuItem; 1.35 -import javax.swing.KeyStroke; 1.36 - 1.37 -/** 1.38 - * 1.39 - * @author mike 1.40 - */ 1.41 -public class MainMenu { 1.42 - 1.43 - private ActionHandler handler; 1.44 - private JMenuBar menuBar; 1.45 - 1.46 - public MainMenu(ActionHandler h) { 1.47 - handler = h; 1.48 - menuBar = new JMenuBar(); 1.49 - menuBar.add(createMenu("Datei", 'd', 1.50 - createMenuItem("Neu", 'n', "control N", ActionHandler.NEW), 1.51 - createMenuItem("Öffnen", 'f', "control O", ActionHandler.OPEN), 1.52 - createMenuItem("Speichern", 's', "control S", ActionHandler.SAVE), 1.53 - createMenuItem("Speichern als...", 'a', ActionHandler.SAVE_AS), 1.54 - createSeparator(), 1.55 - createMenuItem("Prüfen", 'p', "control P", ActionHandler.CHECK), 1.56 - createMenuItem("Lösen", 'l', "control L", ActionHandler.SOLVE), 1.57 - createSeparator(), 1.58 - createMenuItem("Beenden", 'e', ActionHandler.QUIT) 1.59 - )); 1.60 - menuBar.add(createMenu("Help", 'h', 1.61 - createMenuItem("Über...", 'b', "F1", ActionHandler.ABOUT) 1.62 - )); 1.63 - } 1.64 - 1.65 - private JMenuItem createSeparator() { 1.66 - // Return null, the createMenu method knows how to handle it 1.67 - return null; 1.68 - } 1.69 - 1.70 - private JMenu createMenu(String caption, char mnemonic, JMenuItem...items) { 1.71 - JMenu menu = new JMenu(caption); 1.72 - menu.setMnemonic(mnemonic); 1.73 - for (JMenuItem item : items) { 1.74 - if (item == null) { 1.75 - menu.addSeparator(); 1.76 - } else { 1.77 - menu.add(item); 1.78 - } 1.79 - } 1.80 - return menu; 1.81 - } 1.82 - 1.83 - private JMenuItem createMenuItem(String caption, char mnemonic, 1.84 - String command) { 1.85 - return createMenuItem(caption, mnemonic, null, command); 1.86 - } 1.87 - 1.88 - private JMenuItem createMenuItem(String caption, char mnemonic, 1.89 - String stroke, String command) { 1.90 - JMenuItem item = new JMenuItem(caption); 1.91 - item.setMnemonic(mnemonic); 1.92 - if (stroke != null) { 1.93 - item.setAccelerator(KeyStroke.getKeyStroke(stroke)); 1.94 - } 1.95 - item.setActionCommand(command); 1.96 - item.addActionListener(handler); 1.97 - 1.98 - return item; 1.99 - } 1.100 - 1.101 - public JMenuBar getMenuBar() { 1.102 - return menuBar; 1.103 - } 1.104 -}