PageRenderTime 45ms CodeModel.GetById 37ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/bundles/plugins-trunk/CommonControls/common/gui/actions/CustomAction.java

#
Java | 81 lines | 50 code | 16 blank | 15 comment | 0 complexity | b6078092df3d0ff9346b78dd958a7ffe MD5 | raw file
 1package common.gui.actions;
 2
 3import java.awt.event.*;
 4import java.net.*;
 5import javax.swing.*;
 6
 7
 8/**
 9 * An old class that probably should not be used anymore. 
10 *
11 * @author     mace
12 * @created    October 24, 2002
13 * @modified   $Date: 2012-03-13 17:07:11 +0100 (Tue, 13 Mar 2012) $ by $Author: ezust $
14 * @version    $Revision: 21349 $
15 * @deprecated
16 */
17 @Deprecated
18public abstract class CustomAction extends AbstractAction {
19	public final static int CTRL = KeyEvent.CTRL_MASK;
20	public final static int ALT = KeyEvent.ALT_MASK;
21	public final static int SHIFT = KeyEvent.SHIFT_MASK;
22	public final static int META = KeyEvent.META_MASK;
23
24	/**
25	 * The Action's tool tip text is set to it's name by default.
26	 *
27	 * @param name  Description of the Parameter
28	 */
29	public CustomAction(String name) {
30		super(name);
31		setActionCommand(name);
32		setToolTipText(name);
33	}
34
35	public CustomAction(String name, Icon icon) {
36		super(name, icon);
37		setActionCommand(name);
38		setToolTipText(name);
39	}
40
41	public void setToolTipText(String text) {
42		putValue(SHORT_DESCRIPTION, text);
43	}
44
45	public void setContextualHelp(String text) {
46		putValue(LONG_DESCRIPTION, text);
47	}
48
49	public void setAccelerator(KeyStroke ks) {
50		putValue(ACCELERATOR_KEY, ks);
51	}
52
53	public void setAccelerator(int key, int modifiers) {
54		KeyStroke ks = KeyStroke.getKeyStroke(key, modifiers);
55		setAccelerator(ks);
56	}
57
58	public void setMnemonic(int key) {
59		putValue(MNEMONIC_KEY, new Integer(key));
60	}
61
62	public void setName(String name) {
63		putValue(NAME, name);
64	}
65
66	public void setIcon(String file) {
67		//URL iconURL = ClassLoader.getSystemResource(file);
68		ImageIcon icon = new ImageIcon(file);
69		setIcon(icon);
70	}
71
72	public void setIcon(Icon i) {
73		putValue(SMALL_ICON, i);
74
75	}
76
77	public void setActionCommand(String command) {
78		putValue(ACTION_COMMAND_KEY, command);
79	}
80}
81