بتاريخ: 13 مايو 200817 سنة comment_128752 GoalSome mouse triggers like when-mouse-leave and when-mouse-enter are not implemented in web deployed forms. These triggers are functional in client server based forms. For example, these triggers can be used to change the visual attributes of text items dynamically when an user enters and exits with a mouse. How to use a PJC to get the same functionality in web based forms ?SolutionFirst of all you have to know how to create a PJC with Oracle Jdeveloper. You have to create a Clienttier -> Javabean and using the code next.Write a PJC with code as shown below:package mypackage2;import oracle.forms.ui.VTextField;import java.awt.Color.*;import oracle.forms.handler.IHandler;import java.awt.event.*;import oracle.forms.properties.ID;import java.awt.*;public class mymousePJC extends VTextField {private IHandler m_handler;private Color m_backgroundcolor;private Color m_foregroundcolor;private Color m1_backgroundcolor;private Color m1_foregroundcolor;private static final ID ENTER_BACKGROUND_COLOR = ID.registerProperty("ENTER_BACKGROUND_COLOR");private static final ID ENTER_FOREGROUND_COLOR = ID.registerProperty("ENTER_FOREGROUND_COLOR");private static final ID EXIT_BACKGROUND_COLOR = ID.registerProperty("EXIT_BACKGROUND_COLOR");private static final ID EXIT_FOREGROUND_COLOR = ID.registerProperty("EXIT_FOREGROUND_COLOR");public mymousePJC(){super();enablechangetextcolor();}public void init(IHandler handler){m_handler = handler;super.init(handler);}public boolean setProperty(ID pid, Object value){if(pid == ENTER_BACKGROUND_COLOR){m_backgroundcolor= getColor((String)value);return true;}elseif(pid == ENTER_FOREGROUND_COLOR){m_foregroundcolor= getColor((String)value);return true;}elseif(pid == EXIT_FOREGROUND_COLOR){m1_foregroundcolor= getColor((String)value);return true;}elseif(pid == EXIT_BACKGROUND_COLOR){m1_backgroundcolor= getColor((String)value);return true;}elsereturn super.setProperty(pid,value);}public void setForeground(Color p0){// TODO: Override this oracle.ewt.lwAWT.LWComponent methodsuper.setForeground(p0);}public void setBackground(Color p0){// TODO: Override this oracle.ewt.lwAWT.LWComponent methodsuper.setBackground(p0);}private void enablechangetextcolor(){addMouseListener(new changetextcolor());}public Color getColor(String sColor){Color color = null;if(sColor.equalsIgnoreCase("blue"))color = Color.blue;else if (sColor.equalsIgnoreCase("red"))color = Color.red;else if (sColor.equalsIgnoreCase("green"))color = Color.green;else if (sColor.equalsIgnoreCase("white"))color = Color.white;else if (sColor.equalsIgnoreCase("yellow"))color = Color.yellow;else if (sColor.equalsIgnoreCase("orange"))color = Color.orange;return color;}class changetextcolor extends MouseAdapter{public void mouseEntered(MouseEvent me){setForeground(m_foregroundcolor);setBackground(m_backgroundcolor);}public void mouseExited(MouseEvent me){setForeground(m1_foregroundcolor);setBackground(m1_backgroundcolor);}}}Compile the PJC and deploy it in a jar file. Place the jar file in the <oracle_home>/forms/java directory and specify the jar file in the archive_jini tag of formsweb.cfg file. To test this PJC, create a simple form with a text item and a push button. Set the Implementation Class property of the text item to mypackage2.mymousePJC. In the when-button-pressed trigger for the push button, add the following code:set_custom_property('<text_item>',1,'ENTER_FOREGROUND_COLOR','red');set_custom_property('<text_item>',1,'ENTER_BACKGROUND_COLOR','blue');set_custom_property('<text_item>',1,'EXIT_FOREGROUND_COLOR','yellow');set_custom_property('<text_item>',1,'EXIT_BACKGROUND_COLOR','red'); تقديم بلاغ
انضم إلى المناقشة
يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.