Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic setColor() with event LinkMouseEnter (Read 3487 times)
rlira
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 10
Joined: Apr 28th, 2011
setColor() with event LinkMouseEnter
Jul 15th, 2011 at 6:11pm
Print Post  
Hello!

I'm trying to highlight a link when mouse is over it. I added events for MouseEnter and MouseLeave like this:

var = oldlinkColor;

function linkOnMouseEnter(sender, args) {
    oldlinkColor = args.getLink().getPen().getColor();
    args.getLink().getPen().setColor('#FF0000');
}

function linkOnMouseLeave(sender, args) {
    args.getLink().getPen().setColor(oldlinkColor);
}

However, I'm getting an exception on the first line of MouseEnter event.

Debugger tells me "getPen()" isn't available.

Is there any way to achieve my goal?

Thanks in advance.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: setColor() with event LinkMouseEnter
Reply #1 - Jul 15th, 2011 at 6:43pm
Print Post  
Hi,

Are you using ImageMap mode? In such case you can change items' appearance only on the server side, so it won't be possible to set the link's pen from the Enter and Leave handlers. You will have to use Java mode for that.

Stoyan
  
Back to top
 
IP Logged
 
rlira
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 10
Joined: Apr 28th, 2011
Re: setColor() with event LinkMouseEnter
Reply #2 - Jul 18th, 2011 at 5:00pm
Print Post  
Hello!

Yes, I am using ImageMap mode. I tried changing to JavaApplet mode but I get the following:

java.lang.ClassFormatError: Incompatible magic value 218762506 in class file com/mindfusion/diagramming/DiagramApplet
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exceção: java.lang.ClassFormatError: Incompatible magic value 218762506 in class file com/mindfusion/diagramming/DiagramApplet


JDiagram.jar is located at page's folder (I tried setting is programatically but I got the same error) and all references are set.

Any idea on what could be happening?

Again, thanks for helping.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: setColor() with event LinkMouseEnter
Reply #3 - Jul 18th, 2011 at 5:10pm
Print Post  
Hi!

This usually happens when using Forms Authentication; then the server returns some kind of response that the Java plugin cannot recognize.

One work-around is moving the jar file to unprotected area of your site (last discussed here http://mindfusion.eu/Forum/YaBB.pl?board=netdg_disc;action=display;num=131074561...).

Another option is preloading the applet (e.g. a hidden copy) from your login form. If you preload the applet, the browser will have it in the cache and won't try to load it again from the protected pages.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
rlira
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 10
Joined: Apr 28th, 2011
Re: setColor() with event LinkMouseEnter
Reply #4 - Jul 18th, 2011 at 5:41pm
Print Post  
Thank you for your support.

Browser was able to load the applet once I put the JAR file into an unprotected folder.

But yet I can't highlight the link OnMouseOver.

The parameter for setColor should be a Color class.

After looking at java documentation, I tried:

args.getLink().getPen().setColor(new Color(255,0,0));
args.getLink().getPen().getColor().setRed(255);

and finally

args.getLink().getPen().setColor(new java.awt.Color(255,0,0));

The latter won't raise an exception. However the link does not get displayed as red.

I appreciate any help.

Thanks.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: setColor() with event LinkMouseEnter
Reply #5 - Jul 18th, 2011 at 6:04pm
Print Post  
You will have to call setPen for the diagram to repaint automatically, and also you cannot create new Java objects from JavaScript (unless the classes are somewhere in the CLASS_PATH) so you will have to use the create* methods in ScriptHelper:

var applet = <%= diagramView.AppletElement %>;
var pen = applet.getScriptHelper().createPen(width, r, g, b);
args.getLink().setPen(pen);

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint