![]() |
||
![]() |
![]() Alden Hosting provides professional, efficient, and reliable business-class Web hosting services to small- and medium-sized businesses. |
|
|
JAVA, JSP, SERVLETS, TOMCAT, SERVLETS MANAGER, |
|||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
![]() |
Here's the code that disables the "Go left" action:
boolean selected = ...//true if the action should be enabled;
//false, otherwise
leftAction.setEnabled(selected);
After you create components using an Action,
you might well need to customize them.
For example, you might want to customize the
appearance of one of the components
by adding or deleting the icon or text.
For example,
ActionDemo.java
has no icons in its menus, and no text in its buttons.
Here's the code that accomplishes this:
menuItem = new JMenuItem();
menuItem.setAction(leftAction);
menuItem.setIcon(null); //arbitrarily chose not to use icon in menu
...
button = new JButton();
button.setAction(leftAction);
button.setText(""); //an icon-only button
We chose to create an icon-only button and
a text-only menu item from the same action by setting
the icon property to null and the text
to an empty string.
However, if a property of the Action changes, the
widget may try to reset the icon and text from the
Action again.
The following tables list the commonly usedActionconstructors and methods. The API for usingActionobjects falls into three categories:
Components that Support set/getAction Class Purpose AbstractButton
JComboBox
JTextFieldThese components and their subclasses may have an action directly assigned to them via setAction. For further information about components that are often associated with actions, see the sections on tool bar buttons, menu items, common buttons, and text fields. For details on which properties each component takes from theAction, see the API documentation for the relevant class'sconfigurePropertiesFromActionmethod. Also refer to thebuttonActionstable.
Creating and Using an AbstractAction Constructor or Method Purpose AbstractAction()
AbstractAction(String)
AbstractAction(String, Icon)Create an Actionobject. Through arguments, you can specify the text and icon to be used in the components that the action is attached to.void setEnabled(boolean)
boolean isEnabled()Set or get whether the components the action controls are enabled. Invoking setEnabled(false)disables all the components that the action controls. Similarly, invokingsetEnabled(true)enables the action's components.void putValue(String, Object)
Object getValue(String)Set or get an object associated with a specified key. Used for setting and getting properties associated with an action.
This table defines the properties that can be set on an action. The second column lists which components automatically use the properties (and what method is specifically called). For example, setting the
ACCELERATOR_KEYon an action that is then attached to a menu item, means thatJMenuItem.setAccelerator(KeyStroke)is called automatically.
Property Auto-Applied to:
Class
(Method Called)Purpose ACCELERATOR_KEY JMenuItem
(setAccelerator)The KeyStroketo be used as the accelerator for the action. For a discussion of accelerators versus mnemonics, see Enabling Keyboard Operation. Introduced in 1.3.ACTION_COMMAND_KEY AbstractButton,JCheckBox,JRadioButton
(setActionCommand)The command string associated with the ActionEvent.LONG_DESCRIPTION None The longer description for the action. Can be used for context-sensitive help. MNEMONIC_KEY AbstractButton,JMenuItem,JCheckBox,JRadioButton
(setMnemonic)The mnemonic for the action. For a discussion of accelerators versus mnemonics, see Enabling Keyboard Operation. Introduced in 1.3. NAME AbstractButton,JMenuItem,JCheckBox,JRadioButton
(setText)The name of the action. You can set this property when creating the action using the AbstractAction(String)orAbstractAction(String, Icon)constructors.SHORT_DESCRIPTION AbstractButton,JCheckBox,JRadioButton
(setToolTipText)The short description of the action. SMALL_ICON AbstractButton,JMenuItem
(setIcon)The icon for the action used in the tool bar or on a button. You can set this property when creating the action using the AbstractAction(name, icon)constructor.
The following examples useActionobjects.
Example Where Described Notes ActionDemoThis section Uses actions to bind buttons and menu items to the same function. TextComponentDemoText Component Features Uses text actions to create menu items for text editing commands, such as cut, copy, and paste, and to bind key strokes to caret movement. Also implements custom AbstractActionsubclasses to implement undo and redo. The text action discussion begins in Concepts: About Editor Kits.
Alden Hosting offers private JVM (Java Virtual Machine), Java Server Pages (JSP), Servlets, and Servlets Manager with our Web Hosting Plans WEB 4 PLAN and WEB 5 PLAN , WEB 6 PLAN .
At Alden Hosting we eat and breathe Java! We are the industry leader in providing affordable, quality and efficient Java web hosting in the shared hosting marketplace. All our sites run on our Java hosing platform configured for optimum performance using Java 1.6, Tomcat 6, MySQL 5, Apache 2.2 and web application frameworks such as Struts, Hibernate, Cocoon, Ant, etc.
We offer only one type of Java hosting - Private Tomcat. Hosting accounts on the Private Tomcat environment get their very own Tomcat server. You can start and re-start your entire Tomcat server yourself.
![]() |
|
http://alden-servlet-Hosting.com
JSP at alden-servlet-Hosting.com
Servlets at alden-servlet-Hosting.com
Servlet at alden-servlet-Hosting.com
Tomcat at alden-servlet-Hosting.com
MySQL at alden-servlet-Hosting.com
Java at alden-servlet-Hosting.com
sFTP at alden-servlet-Hosting.com
http://alden-tomcat-Hosting.com
JSP at alden-tomcat-Hosting.com
Servlets at alden-tomcat-Hosting.com
Servlet at alden-tomcat-Hosting.com
Tomcat at alden-tomcat-Hosting.com
MySQL at alden-tomcat-Hosting.com
Java at alden-tomcat-Hosting.com
sFTP at alden-tomcat-Hosting.com
http://alden-sftp-Hosting.com
JSP at alden-sftp-Hosting.com
Servlets at alden-sftp-Hosting.com
Servlet at alden-sftp-Hosting.com
Tomcat at alden-sftp-Hosting.com
MySQL at alden-sftp-Hosting.com
Java at alden-sftp-Hosting.com
sFTP at alden-sftp-Hosting.com
http://alden-jsp-Hosting.com
JSP at alden-jsp-Hosting.com
Servlets at alden-jsp-Hosting.com
Servlet at alden-jsp-Hosting.com
Tomcat at alden-jsp-Hosting.com
MySQL at alden-jsp-Hosting.com
Java at alden-jsp-Hosting.com
sFTP at alden-jsp-Hosting.com
http://alden-java-Hosting.com
JSp at alden-java-Hosting.com
Servlets at alden-java-Hosting.com
Servlet at alden-java-Hosting.com
Tomcat at alden-java-Hosting.com
MySQL at alden-java-Hosting.com
Java at alden-java-Hosting.com
sFTP at alden-java-Hosting.com
JSP
Servlets
Tomcat
mysql
Java
JSP
Servlets
Tomcat
mysql
Java
JSP
Servlets
Tomcat
mysql
Java
JSP
Servlets
Tomcat
mysql
Java
JSP at JSP.aldenWEBhosting.com
Servlets at servlets.aldenWEBhosting.com
Tomcat at Tomcat.aldenWEBhosting.com
mysql at mysql.aldenWEBhosting.com
Java at Java.aldenWEBhosting.com
Web Hosts Portal
Web Links
Web Links
Web Hosting
JSP Solutions Web Links
JSP Solutions Web Hosting
Servlets Solutions Web Links
Servlets Solutions Web Hosting
Web Links
Web Links
.
.
.
.
.
.
.
.
.
.
jsp hosting
servlets hosting
web hosting
web sites designed
cheap web hosting
web site hosting
myspace web hosting