You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by ps...@apache.org on 2003/05/01 05:26:09 UTC

cvs commit: jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw FileMenu.java

psmith      2003/04/30 20:26:09

  Added:       src/java/org/apache/log4j/chainsaw FileMenu.java
  Log:
  Added FileMenu, which encapsulates all the Menus and Actions for that
  menu.
  
  Revision  Changes    Path
  1.1                  jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/FileMenu.java
  
  Index: FileMenu.java
  ===================================================================
  /*
   * @author Paul Smith <ps...@apache.org>
   *
  */
  package org.apache.log4j.chainsaw;
  
  import java.awt.event.ActionEvent;
  import java.awt.event.InputEvent;
  import java.awt.event.KeyEvent;
  
  import javax.swing.AbstractAction;
  import javax.swing.Action;
  import javax.swing.JMenu;
  import javax.swing.JMenuItem;
  import javax.swing.JPanel;
  import javax.swing.JSeparator;
  import javax.swing.KeyStroke;
  
    /**
     * The complete File Menu for the main GUI, containing
     * the Load, Close Welcome Tab, and Exit actions
     * 
     * @author Paul Smith <ps...@apache.org>
     */
  class FileMenu extends JMenu {
  
  
    public FileMenu(final LogUI logUI) {
      super("File");
      setMnemonic(KeyEvent.VK_F);
      
  
      JMenuItem loadFile = new JMenuItem(new FileLoadAction(logUI));
      
      Action closeAction = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
          JPanel somepanel = (JPanel) logUI.tabbedPane.getSelectedComponent();
  
          if (!(somepanel instanceof LogUI.LogPanel)) {
            logUI.tabbedPane.remove(somepanel);
          }
        }
      };
      closeAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.ALT_MASK));
      closeAction.putValue(Action.SHORT_DESCRIPTION, "Removes the Welcome tab");
      closeAction.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_C));
      closeAction.putValue(Action.NAME, "Close Welcome tab");
      
      
      JMenuItem menuItemClose = new JMenuItem(closeAction);
      
      Action exitAction = new AbstractAction() {
  
        public void actionPerformed(ActionEvent e) {
          System.exit(0);
        }
      };
  
      exitAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.ALT_MASK));
      exitAction.putValue(Action.SHORT_DESCRIPTION, "Exits the Application");
      exitAction.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_X));
      exitAction.putValue(Action.NAME, "Exit");
      
      JMenuItem menuItemExit = new JMenuItem(exitAction);
      
      
      add(loadFile);
      add(menuItemClose);
      add(new JSeparator());
      add(menuItemExit);
    }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org