/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 info.ineighborhood.cardme.ui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;
import javax.swing.text.DefaultEditorKit;
/**
* Copyright (c) 2004, Neighborhood Technologies
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of Neighborhood Technologies nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
*
* @author George El-Haddad
* <br/>
* Nov 12, 2010
*
*/
public class CardmeFrame extends JFrame {
private JMenuBar menuBar = null;
private JMenu fileMenu = null;
private JMenuItem newMenuItem = null;
private JMenuItem openMenuItem = null;
private JMenuItem closeMenuItem = null;
private JMenuItem closeAllMenuItem = null;
private JMenuItem saveMenuItem = null;
private JMenuItem saveAsMenuItem = null;
private JMenuItem saveAllMenuItem = null;
private JMenuItem exitMenuItem = null;
private JMenu editMenu = null;
private JMenuItem cutMenuItem = null;
private JMenuItem copyMenuItem = null;
private JMenuItem pasteMenuItem = null;
private JMenu helpMenu = null;
private JMenuItem aboutMenuItem = null;
public CardmeFrame() {
init();
}
private void init() {
/*
* New
*/
newMenuItem = new JMenuItem("New");
newMenuItem.setMnemonic(KeyEvent.VK_N);
newMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
/*
* Open
*/
openMenuItem = new JMenuItem("Open File ...");
openMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
/*
* Close
*/
closeMenuItem = new JMenuItem("Close");
closeMenuItem.setMnemonic(KeyEvent.VK_C);
closeMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
/*
* Close All
*/
closeAllMenuItem = new JMenuItem("Close All");
closeAllMenuItem.setMnemonic(KeyEvent.VK_L);
closeAllMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
/*
* Save
*/
saveMenuItem = new JMenuItem("Save", null);
saveMenuItem.setMnemonic(KeyEvent.VK_S);
saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK));
saveMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
/*
* Save As
*/
saveAsMenuItem = new JMenuItem("Save As ...", null);
saveAsMenuItem.setMnemonic(KeyEvent.VK_A);
saveAsMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
/*
* Save All
*/
saveAllMenuItem = new JMenuItem("Save All", null);
saveAllMenuItem.setMnemonic(KeyEvent.VK_E);
saveAllMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
/*
* Exit
*/
exitMenuItem = new JMenuItem("Exit");
exitMenuItem.setMnemonic(KeyEvent.VK_X);
exitMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
exit_actionPerformed();
}
});
aboutMenuItem = new JMenuItem("About");
aboutMenuItem.setMnemonic(KeyEvent.VK_A);
aboutMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
/*
* Cut
*/
cutMenuItem = new JMenuItem(new DefaultEditorKit.CutAction());
cutMenuItem.setText("Cut");
cutMenuItem.setMnemonic(KeyEvent.VK_T);
/*
* Copy
*/
copyMenuItem = new JMenuItem(new DefaultEditorKit.CopyAction());
copyMenuItem.setText("Copy");
copyMenuItem.setMnemonic(KeyEvent.VK_C);
/*
* Paste
*/
pasteMenuItem = new JMenuItem(new DefaultEditorKit.PasteAction());
pasteMenuItem.setText("Paste");
pasteMenuItem.setMnemonic(KeyEvent.VK_P);
/*
* Help Menu
*/
helpMenu = new JMenu("Help");
helpMenu.setMnemonic(KeyEvent.VK_H);
helpMenu.add(aboutMenuItem);
/*
* Edit Menu
*/
editMenu = new JMenu("Edit");
editMenu.setMnemonic(KeyEvent.VK_E);
editMenu.add(cutMenuItem);
editMenu.add(copyMenuItem);
editMenu.add(pasteMenuItem);
/*
* File Menu
*/
fileMenu = new JMenu("File");
fileMenu.setMnemonic(KeyEvent.VK_F);
fileMenu.add(newMenuItem);
fileMenu.add(openMenuItem);
fileMenu.addSeparator();
fileMenu.add(closeMenuItem);
fileMenu.add(closeAllMenuItem);
fileMenu.addSeparator();
fileMenu.add(saveMenuItem);
fileMenu.add(saveAsMenuItem);
fileMenu.add(saveAllMenuItem);
fileMenu.addSeparator();
fileMenu.add(exitMenuItem);
/*
* Menu Bar
*/
menuBar = new JMenuBar();
menuBar.add(fileMenu);
menuBar.add(editMenu);
menuBar.add(helpMenu);
setJMenuBar(menuBar);
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
exit_actionPerformed();
}
});
}
private void exit_actionPerformed() {
super.setVisible(false);
super.dispose();
System.exit(0);
}
}