/** * Copyright 1999-2009 The Pegadi Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.pegadi.games.tetris.actions; import org.pegadi.games.tetris.Tetris; import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ResourceBundle; /** * Created by IntelliJ IDEA. * User: anderlin * Date: Feb 22, 2006 * Time: 12:49:50 AM * To change this template use File | Settings | File Templates. */ public class NewGameAction extends AbstractAction { private Tetris tetris; public NewGameAction(Tetris tetris) { this.tetris = tetris; ResourceBundle strings = ResourceBundle.getBundle("org.pegadi.games.tetris.TetrisStrings"); putValue(AbstractAction.NAME, strings.getString("new_game")); //putValue(AbstractAction.MNEMONIC_KEY, "N"); putValue(AbstractAction.ACCELERATOR_KEY, javax.swing.KeyStroke.getKeyStroke(78, java.awt.event.KeyEvent.CTRL_MASK, false)); ImageIcon icon = new ImageIcon(getClass().getResource(strings.getString("icon_new"))); putValue(AbstractAction.SMALL_ICON, icon); } public void actionPerformed(ActionEvent actionEvent) { tetris.startGame(); } }