Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Liveconnect- background color

 
Venkata Kiran
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai All,
can v change the backgrouund color of an applet based on user selection using Javascript.
Thanks.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, using LiveConnect that's possible. What do you have so far?
 
Venkata Kiran
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I must accept a color from a textbox and on button click must set new color as the background color. I tried onKlick="document.AppletName.setBackgroundColordocument.form1.textBox.value)
I am getting an error : Object does not support this property.
i had just started working with LiveConnect ,
r there any good links for this.
Thank You.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
onKlick="document.AppletName.setBackgroundColordocument.form1.textBox.value)

I assume that's just a typo, and you really have (i.e., there is an opening parenthesis):
document.AppletName.setBackgroundColor(document.form1.textBox.value)

I'm not sure if the error message is about the HTML form or the applet. Do an "alert(document.form1.textBox.value)" before you call the applet method, just to see if the correct value is transmitted.

Also, the setBackgroundColor method must be declared public for this to work.

The Applet FAQ -linked in my signature- has a section on LiveConnect which will get you started.
[ January 02, 2006: Message edited by: Ulf Dittmer ]
 
Venkata Kiran
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The setBackground color is declared as public and the alert statements are displaying the correct values entered in textboxes.

but still i am getting an error java.lang.Exception:setBackgroundColor(0): no such method exists;
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What type has the parameter of setBackgroundColor? I'm not sure how well passing integers works - try declaring it as a String, and converting that to int in the Java code.
 
Venkata Kiran
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok got an excellent link which almost suits my requirement at
www.experts-exchange.com
Thnaks You for the Help.

[ link edited by UD to keep the formatting readable ]
[ January 03, 2006: Message edited by: Ulf Dittmer ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic