Quick Search for:  in language:    
RGB,Description,simple,java,applet,shows,para
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
Java/ Javascript Stats

 Code: 220,465. lines
 Jobs: 92. postings

 How to support the site

 
Sponsored by:

 
You are in:
 
Login





Latest Code Ticker for Java/ Javascript.
Click here to see a screenshot of this code!vok - The vocabulary trainer
By Thorsten Stärk on 1/7

(Screen Shot)

Java, Calculator
By Rockwell on 1/4


Eatable Interface
By Rockwell on 1/4


Superclass Person
By Rockwell on 1/4


Draws Cube Function
By Rockwell on 1/4


Rectangle Class
By Rockwell on 1/4


Find Number of Upper and Lower Case Letters in a Command Line Argument String
By Rockwell on 1/4


anagrams
By Rockwell on 1/4


Text Reader with Tokenizer
By Rockwell on 1/4


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!

Affiliate Sites



 
 
   

Using Parameters

Print
Email
 
VB icon
Submitted on: 12/20/2001 6:52:10 PM
By: Randy McCleary 
Level: Intermediate
User Rating: By 5 Users
Compatibility:Java (JDK 1.2)

Users have accessed this code 5782 times.
 
(About the author)
 
     Description: This is a simple java applet that shows how to get parameters from the html file and use them inside java. Remember Java is case sensitive, so the names in the html file must match your getParameter() names. Ex. html-PARAM NAME=Text Java-getParameter("Text"). It also shows how to convert hex color inputs to RGB color to use in Java.
 

HTML:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!

//**************************************
//     
//HTML for :Using Parameters
//**************************************
//     
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>
HTML Test Page
</TITLE>
</HEAD>
<BODY>
<APPLET CODEBASE="myclasses" CODE="parameters.class" WIDTH=400 HEIGHT=300 HSPACE=0 VSPACE=0 ALIGN=middle>
<PARAM NAME=Text VALUE="This is sample text.">
<PARAM NAME=FontName VALUE="Courier">
<PARAM NAME=FontStyle VALUE="1">
<PARAM NAME=FontSize VALUE="20">
<PARAM NAME=bgColor VALUE="CCCCCC">
<PARAM NAME=fontColor VALUE="FF0000">
</APPLET>
</BODY>
</HTML>
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

//**************************************
//     
// Name: Using Parameters
// Description:Description: This is a si
//     mple java applet that shows how to get p
//     arameters from the html file and use the
//     m inside java. Remember Java is case sen
//     sitive, so the names in the html file mu
//     st match your getParameter() names. Ex. 
//     html-PARAM NAME=Text Java-getParameter("
//     Text"). It also shows how to convert hex
//     color inputs to RGB color to use in Java
//     .
// By: Randy McCleary
//
//This code is copyrighted and has// limited warranties.Please see http://
//     www.Planet-Source-Code.com/vb/scripts/Sh
//     owCode.asp?txtCodeId=2533&lngWId;=2//for details.//**************************************
//     

//**************************************
//     **********
//Author: Randy McCleary
//File Name: parameters.java
//Program: How to understand parameters.
//     
//Description: This is a simple java app
//     let that
// shows how to get parameters from the 
//     html file 
// and use them inside java. Remember Ja
//     va is 
// case sensitive, so the names in the h
//     tml file 
// must match your getParameter() names.
//     Ex. 
// html-PARAM NAME=Text Java-getParamete
//     r("Text").
// It also shows how to convert hex colo
//     r inputs
// to RGB color to use in Java.
//**************************************
//     *********
package parameters;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import java.awt.color.*;
import java.awt.FlowLayout;
import java.awt.Label.*;
public class parameters extends Applet
    {
    	String text1;
    	String text2;
    	String text3;
    	String text4;
    	String text5;
    	String fontName;
    	int bgColorIndex;
    	int fontColorIndex;
    	int fontSize;
    	int fontStyle;
    	Color bgColor;
    	Color fontColor;
    	Font newFont1;
    	Font newFont2;
    	Font newFont3;
    	Font newFont4;
    	Font newFont5;
    	FontMetrics fontMetrics;
    	Graphics offbuff;
    	Label output;
    	public void init()
        	{
        	 //Get "Text" input parameter from html file.
        	 //Get "fontName" parameter from html file
        	 text1 = getParameter("Text1");
        	 text2 = getParameter("Text2");
        	 text3 = getParameter("Text3");
        	 text4 = getParameter("Text4");
        	 text5 = getParameter("Text5");
        	 fontName = getParameter("FontName");
        	 //Get fontStyle value. Values range from 0-3
        	 //Style Values- Plain=0 Bold=1 Italic=2
        	 //Bold&Italic;=3
        	 fontStyle = Integer.valueOf(getParameter("FontStyle")).intValue();
        	 //Get fontSize value from parameter list.
        	 fontSize = Integer.valueOf(getParameter("FontSize")).intValue();
        	 //Create the new font thats going to be used.
        	 newFont = new Font(fontName, fontStyle, fontSize);
        	 fontMetrics = getFontMetrics(newFont);
        	 //Get bgcolor parameter from html file
        	 //Then convert it from hex to integer "FFFFFF - RGB"
        	 //The 1st 2 FF's is the Red
        	 //The 2nd 2 FF's is the Green
        	 //The 3rd 2 FF's is the Blue
        	 //FF = 16^2 - 1 = 255
        	 //So FFFFFF is equal to 255,255,255
        	 bgColorIndex = Integer.parseInt(getParameter("bgColor"), 16);
        	 bgColor = new Color(bgColorIndex);
        	 fontColorIndex = Integer.parseInt(getParameter("fontColor"), 16);
        	 fontColor = new Color(fontColorIndex);
        	 //Set the bgcolor and fontcolor to the RGB color just created
        	 setBackground(bgColor);
        	 setForeground(fontColor);
        	 //Define what type of layout you would like to use
        	 //This is in the Swing library.
        	 setLayout(new FlowLayout(FlowLayout.CENTER));
        	 //Put the input text on a label then set the 
        	 //font on the label created.
        	 output = new Label(text1);
        	 output.setFont(newFont1);
        	 output = new Label(text2);
        	 output.setFont(newFont2);
        	 output = new Label(text3);
        	 output.setFont(newFont3);
        	 output = new Label(text4);
        	 output.setFont(newFont4);
        	 output = new Label(text5);
        	 output.setFont(newFont5);
        	 //Adds the label to display on the applet.
        	 add(output);
        	}
        	public parameters()
            	{
            		fontName = "Arial";
            	}
        }


Other 9 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
12/20/2001 7:48:55 PM:kc
You ask and you shall recieve. Thanks 
Randy for this great piece of code. I'm 
off to see what kind of new funstuff I 
can make with this ;)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/21/2001 3:05:09 AM:Jason
Nice code, thanks it will come in handy 
when i start on programming applets.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/21/2001 3:53:40 PM:Josh
Hey nice little piece of code there. It 
should come in handy, for writing 
applets. Do you think you can show some 
more dealing with input parameters? 
Well thanks again.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | Java/ Javascript Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.