• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

passing parameters....how to for fonts and colors

 
tyler jones
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm just starting to learn applets and I've been reading about passing parameters to an applet to set up a message to be displayed. So, I figured that I could also set up an applet to use the getParameter method for the foreground color, background color, and message to display. However, I'm getting errors when I try to compile it and was wondering if you have to do something special when using the getParameter for the colors? Thanks. Here's my code if it helps clear up what I'm trying to do.

[This message has been edited by tyler jones (edited December 12, 2000).]
[This message has been edited by tyler jones (edited December 12, 2000).]
 
Tanveer Rameez
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
In setbackground you have to pass a Color object not a string.
black in Color.black is not a string. So you can't replace Color.black with Color.c where c="black";
what you can do is :
[code]
if(c.equals("black")) setBackground(Color.black)
if(c.equals("red")) setBackground(Color.red)
[code]
I know this is not a convenient way, but that will solve your problem. I think someone else can give a better way of changing the color of the applet based on the paremeter passed.
bye
Tanveer
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic