View Javadoc

1   /*
2   
3   nextobjects Copyright (C) 2001-2005 Emmanuel Florent
4   
5   This program is free software; you can redistribute it and/or modify
6   it under the terms of the GNU General Public License as published by the
7   Free Software Foundation; either version 2 of the License, or (at your
8   option) any later version.
9   
10  This program is distributed in the hope that it will
11  be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12  of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13  PURPOSE. See the GNU General Public License for more details.
14  
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc., 59
17  Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  
19  */
20  package org.devaki.nextobjects.ui.components;
21  import javax.swing.ImageIcon;
22  import javax.swing.JMenuItem;
23  import javax.swing.KeyStroke;
24  import org.devaki.nextobjects.constants.CstImages;
25  /***
26   * This class overwrite the 'JMenuItem' component
27   */
28  public class CustomMenuItem extends JMenuItem
29  {
30      /***
31       * Construct a 'CustomMenuItem' object
32       * @param label Name
33       * @param mnemonic Shortcut letter
34       * @param isEnabled Is the component enabled
35       */
36      public CustomMenuItem(
37          final String label,
38          final int mnemonic,
39          final boolean isEnabled)
40      {
41          super(label, mnemonic);
42          // Set a blank icon to set the offset to 20 pixels
43          this.setIcon(CstImages.ICN_BLANK);
44          // Enable/Disable
45          this.setEnabled(isEnabled);
46      }
47      /***
48       * Construct a 'CustomMenuItem' object
49       * @param label Name
50       * @param icon Icon
51       * @param mnemonic Shortcut letter
52       * @param isEnabled Is the component enabled
53       */
54      public CustomMenuItem(
55          final String label,
56          final ImageIcon icon,
57          final int mnemonic,
58          final boolean isEnabled)
59      {
60          super(label, mnemonic);
61          // Set the icon
62          this.setIcon(icon);
63          // Enable/Disable
64          this.setEnabled(isEnabled);
65      }
66      /***
67       * Construct a 'CustomMenuItem' object
68       * @param label Name
69       * @param mnemonic Shortcut letter
70       * @param accelerator Shortcut keys
71       * @param isEnabled Is the component enabled
72       */
73      public CustomMenuItem(
74          final String label,
75          final int mnemonic,
76          final KeyStroke accelerator,
77          final boolean isEnabled)
78      {
79          super(label, mnemonic);
80          // Set a blank icon to set the offset to 20 pixels
81          this.setIcon(CstImages.ICN_BLANK);
82          // Define the shortcut keys
83          this.setAccelerator(accelerator);
84          // Enable/Disable
85          this.setEnabled(isEnabled);
86      }
87      /***
88       * Construct a 'CustomMenuItem' object
89       * @param label Name
90       * @param icon Icon
91       * @param mnemonic Shortcut letter
92       * @param accelerator Shortcut keys
93       * @param isEnabled Is the component enabled
94       */
95      public CustomMenuItem(
96          final String label,
97          final ImageIcon icon,
98          final int mnemonic,
99          final KeyStroke accelerator,
100         final boolean isEnabled)
101     {
102         super(label, mnemonic);
103         // Set the icon
104         this.setIcon(icon);
105         // Define the shortcut keys
106         this.setAccelerator(accelerator);
107         // Enable/Disable
108         this.setEnabled(isEnabled);
109     }
110 }