| XJMenuItem |

    1   /*  XJMenuItem.java
    2    *
    3    *  Copyright (c) 1998-2001, The University of Sheffield.
    4    *
    5    *  This file is part of GATE (see http://gate.ac.uk/), and is free
    6    *  software, licenced under the GNU Library General Public License,
    7    *  Version 2, June 1991 (in the distribution as file licence.html,
    8    *  and also available at http://gate.ac.uk/gate/licence.html).
    9    *
    10   *  Valentin Tablan 02/04/2001
    11   *
    12   *  $Id: XJMenuItem.java,v 1.2 2001/04/11 16:58:57 oana Exp $
    13   *
    14   */
    15
    16  package gate.swing;
    17
    18  import javax.swing.JMenuItem;
    19  import javax.swing.*;
    20  import java.awt.event.*;
    21
    22  import gate.event.*;
    23
    24  public class XJMenuItem extends JMenuItem {
    25
    26    public XJMenuItem(Icon icon, String description, StatusListener listener){
    27      super(icon);
    28      this.description = description;
    29      this.listener = listener;
    30      initListeners();
    31    }// public XJMenuItem(Icon icon, String description, StatusListener listener)
    32
    33    public XJMenuItem(String text, String description, StatusListener listener){
    34      super(text);
    35      this.description = description;
    36      this.listener = listener;
    37      initListeners();
    38    }// XJMenuItem(String text, String description, StatusListener listener)
    39
    40    public XJMenuItem(Action a, StatusListener listener){
    41      super(a);
    42      this.description = (String)a.getValue(a.SHORT_DESCRIPTION);
    43      this.listener = listener;
    44      initListeners();
    45    }// XJMenuItem(Action a, StatusListener listener)
    46
    47    public XJMenuItem(String text, Icon icon,
    48                      String description, StatusListener listener){
    49      super(text, icon);
    50      this.description = description;
    51      this.listener = listener;
    52      initListeners();
    53    }// XJMenuItem
    54
    55    public XJMenuItem(String text, int mnemonic,
    56                      String description, StatusListener listener){
    57      super(text, mnemonic);
    58      this.description = description;
    59      this.listener = listener;
    60      initListeners();
    61    }
    62
    63    protected void initListeners(){
    64      this.addMouseListener(new MouseAdapter() {
    65        public void mouseEntered(MouseEvent e) {
    66          listener.statusChanged(description);
    67        }
    68
    69        public void mouseExited(MouseEvent e) {
    70          listener.statusChanged("");
    71        }
    72      });
    73    }// void initListeners()
    74
    75    private StatusListener listener;
    76    String description;
    77  }// class XJMenuItem extends JMenuItem

| XJMenuItem |