Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

applet problem

 
salvador rcn
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, i wanted to see my applet "red".
so i wrote
but , applet is not coming in "red" . whats the problem ? how can i do it?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Applets.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm assuming there is code in your applet to read this parameter and change the color of something? Unless you take some specific action based on the value of the parameter, it will just be ignored. Java takes no actions at all on applet parameters by itself.
 
salvador rcn
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, Ernest Friedman , my applet is running.
however, i wanted to see the applet to be "red".so, i usued that way by "param" variable.
is it not the way to do that ? then what is the use of "param" variable?
my applet code has only init() method and have buttons only.
can you tell me which way, i can get mine applets color to be "red"?
have i done anything wrong in that "snippet" posted above?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "param" tag is a way for your code to receive "arguments" from the HTML file. Java itself will not do anything in response to these parameters; the applet itself would have to call getParameter("color"), which would return the String "red". If you meant for this to set the applet background to be red, you would have to include code something like

If the applet contains no such code, then your parameter will have no effect at all.
 
salvador rcn
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, Ernest Friedman
thanks, i wrote simply setBackground(Color.RED) in my applet init() method.
and it has produced the red applet.
so, i can ignore the param tag, bcoz i can directly write Color.red in the applet itself...so, whats the use of param tag?...can you show a small example where param tag is helpful?

one more thing i had another variable "value" that has not been usued anywhere.

so, ultimately, i feel, this "param" tag is meaningless, i can bypass it by writing appropriate things in the applet methods...is not it?
and oher thing that i have noticed is, Color.red and Color.RED are both producing red applet...so how java is case-sensative?
 
Craig Jackson
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my opinion, the param tag is usefull for alot things but to me it is form of protected variations. And what I mean by that is that if something is likely to change make it so you don't have to modify the core source. A database, property files and config files are usefull in making your programs extensible, more flexible.
For example you could have set the param tag to "red" or "blue" "green" and in your source code you could have done something like this:
setBackground(Color.getColor(getParameter("color"));
This way you no longer need to modify your source code, you can change the background just by changing the param value. I haven't tested the above code so keep that in mind.
Also java is case-sensitive. There are two version of each color i.e. Color.red and Color.RED, Color.green and Color.GREEN.
I hope this helps and makes since.
Craig
 
salvador rcn
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the param tag is usefull for alot things but to me it is form of protected variations. And what I mean by that is that if something is likely to change make it so you don't have to modify the core source. A database, property files and config files are usefull in making your programs extensible, more flexible....... This way you no longer need to modify your source code, you can change the background just by changing the param value

hmmmm....thats a very good and reasonable point.
There are two version of each color i.e. Color.red and Color.RED, Color.green and Color.GREEN.

what do u mean by two version? i have tested with Color.red and Color.RED..both of them has showed redness. i dont find any difference between two redness...may be there are very small difference between two redness...is it like that?
 
Craig Jackson
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, what I meant was that one is lowercase(Color.red) and the other is uppercase(Color.RED). But they are both the same color.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The lowercase ones were there originally. The uppercase ones were added later to adhere to the Java convention that constants should be named in all uppercase.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic