• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Did Steve tell you that? Fuh - Steve. Just look at this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic