There are several ways you can customize your user interface using Pluggable Java Components (PJCs):
Each type of customization has its own steps, described below.
Note: You can
use any code editor to create the Java classes, but to speed your code development,
use Oracle JDeveloper. JDeveloper contains a Pluggable Java Components Wizard
that can access all Forms component classes. Use the wizard to choose
the class of the Forms component that you want to customize, and JDeveloper
generates the skeleton code that extends the IView
interface. All
you have to do is add your own code to the file that defines the functionality
you want, and include the file in your Forms codebase. For more information on the Pluggable Java Components Wizard,
see the JDeveloper Online help.
To extend an existing Forms class:
setProperty()
and/or getProperty()
methods to handle properties.To extend a non-Forms class
IView
interface (the class to be extended could be a class from the JFL or a third-party class).getProperty()
and setProperty()
methods.
These must handle the properties that Forms specifies normally for that class
of user-interface item.To create a container class
IView
interface.getProperty
and setProperty
methods
to handle the properties, such that the appropriate methods on the component
are invoked.To create a new type of interface element
IView
interface.The Forms-supplied class definitions for user interface components are:
To obtain the appearance of interface components offered by the Oracle Look
and Feel (for example, rounded buttons), add <param name = "LookAndFeel"
value = "Oracle">
and <param name = "LookAndFeel"
value = "ColorScheme">
to the HTML file.
import oracle.forms.ui.VButton; import oracle.ewt.button.PushButton; public class SingleButton extends VButton { public SingleButton() { super(); setLeftmost(true); setRightmost(true); } }
package oracle.forms.jfcplug; import com.sun.java.swing.*; import com.sun.java.swing.border.*; import com.sun.java.swing.event.*; import java.awt.*; import java.awt.event.*; import java.util.EventListener; import oracle.forms.handler.IHandler; import oracle.forms.properties.ID; import oracle.forms.ui.IView; public class VJCheckBox extends JCheckBox implements IView { /* Instance counter used to generate default names */ private static int sInstanceCounter; /* Helper class to handle the IView interface */ private IHandler mHandler; private int mInstance; /** ** Constructs a new JCheckBox. */ public VJCheckBox() { super(); mInstance = sInstanceCounter++; } /** ** Implementation of IView interface ** ** @param handler - message handler associated with this view. ** @see IView */ public void init(IHandler handler) { mHandler = handler; } /** ** Implementation of IView interface ** ** @see IView */ public void destroy() { } /** ** Implementation of IView interface ** ** @param id - property id ** @return the value of the property id ** @see IView */ public Object getProperty(ID id) { switch ( id.toID() ) { case ID.INDEX_BOUNDS: return getBounds(); case ID.INDEX_ENABLED: return isEnabled() ? Boolean.TRUE : Boolean.FALSE; case ID.INDEX_LANGUAGE_DIRECTION: return mDirection; case ID.INDEX_LOCATION: return getLocation(); case ID.INDEX_SIZE: return getSize(); case ID.INDEX_VISIBLE: return isVisible() ? Boolean.TRUE : Boolean.FALSE; case ID.INDEX_UI_PARENT: return getParent(); case ID.INDEX_LABEL: return getText(); case ID.INDEX_VALUE: return isSelected() ? Boolean.TRUE : Boolean.FALSE; default: return null; } } /** ** Implementation of IView interface ** ** @param id - property to be set. ** @param value - value of the property id. ** @return - true(if the property could be set), false otherwise. ** @see IView */ public boolean setProperty(ID id, Object value) { switch ( id.toID() ) { case ID.INDEX_BACKGROUND: Color bgColor = (Color) value; setBackground(bgColor); return true; case ID.INDEX_ENABLED: setEnabled(toBoolean(value)); return true; case ID.INDEX_FOCUS: // Only settable to true:-) if ( value == Boolean.TRUE ) { cp.requestFocus(); } return true; case ID.INDEX_FONT: setFont((Font) value); return true; case ID.INDEX_FOREGROUND: Color fgColor = (Color) value; setForeground(fgColor); return true; case ID.INDEX_LANGUAGE_DIRECTION: // Adjust the alignment to conform to the new lang direction // setDirection((LanguageDirection)value); return true; case ID.INDEX_LOCATION: setLocation((Point) value); return true; case ID.INDEX_SIZE: Point pt = (Point) value; setSize(pt.x, pt.y); return true; case ID.INDEX_VISIBLE: setVisible(((Boolean)value).booleanValue()); return true; case ID.INDEX_LABEL: setText((String)value); return true; case ID.INDEX_VALUE: setSelected(((Boolean)value).booleanValue()); return true; default: return false; } } /** ** Implementation of IView interface ** ** @param type - Class type of the listener. ** @param listener - Listener object. ** @see IView */ public void addListener(Class type, EventListener listener) { if ( type == FocusListener.class ) { addFocusListener((FocusListener) listener); } else if ( type == KeyListener.class ) { addKeyListener((KeyListener) listener); } else if ( type == MouseListener.class ) { addMouseListener((MouseListener) listener); } else if ( type == MouseMotionListener.class ) { addMouseMotionListener((MouseMotionListener) listener); } else if ( type == ItemListener.class ) { addItemListener((ItemListener) listener); } } /** ** Implementation of IView interface ** ** @param type - Class type of the listener. ** @param listener - Listener object. ** @see IView */ public void removeListener(Class type, EventListener listener) { if ( type == FocusListener.class ) { removeFocusListener((FocusListener) listener); } else if ( type == KeyListener.class ) { removeKeyListener((KeyListener) listener); } else if ( type == MouseListener.class ) { removeMouseListener((MouseListener) listener); } else if ( type == MouseMotionListener.class ) { removeMouseMotionListener((MouseMotionListener) listener); } else if ( type == ItemListener.class ) { removeItemListener((ItemListener) listener); return; } } /** ** Implementation of IView interface ** ** @param child - Object to be added( or inserted in Lists, Choice) ** @param index - The position of insertion. For add's, this is -1. ** @see IView */ public void add(Object child, int index) { // Not supported } /** ** Implementation of IView interface ** ** @child - Element to be deleted from the list. ** @see IView */ public void remove(Object child) { // Not supported  } /** ** Implementation of IView interface */ public void removeAll() { // Not supported } /** ** Implement getDefaultName() to return a default name of ** the form <ClassName># where # is the instance number ** of the CheckBox */ protected String getDefaultName() { return getClass().getName() + mInstance; } }
Extending Your Application with Pluggable Java Components