• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

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
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic