Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

getParameter() function breaks my loops...

843789Jul 14 2009 — edited Jul 14 2009
I'm trying to build an array of indices over which to iterate using a WHILE loop. The indices are passed to my java applet from a known parameter name using the function getParameter(that_name).

Once the array is built over which to iterate; I want to get each parameter associated with the param names specified by that array from my HTML and draw the parameter values using drawString() one-by-one.

The array is properly built, the arguments being passed to getParameter are right. The problem is that it stops after only the first iteration of the loop.

Here is my code:

THE JAVA:
import java.applet.*;
import java.awt.*;
import java.lang.Math.*;
import java.lang.String;
import java.lang.reflect.Array;

public class DenGen extends Applet {
@Override
public void paint(Graphics g) {
int radius = 250;
int layers = Integer.parseInt(getParameter("layers"));
int nodes = Integer.parseInt(getParameter("nodes"));
double radii = radius/(layers+2);
boolean String;
String delimeter = ",";
String call = Integer.toString(layers-1);
String make_layer = "00";
String fin = call.concat(make_layer);
String str = getParameter(fin);
String[] final_layer = str.split(delimeter);
int start = 0;
int stop = 0;
int index = 0;
int i = 0;
String param;
while(Integer.parseInt(final_layer) < Array.getLength(final_layer)){
param = getParameter(Integer.toString(i));
g.drawString((String) getParameter(Integer.toString(i)), 250, 10);
i++;
}
}
}

THE HTML:

<html>
<head>
<style type = text/css>
.applet{
border: 1px solid black;
}
</style>
</head>
<body>

<center>
<APPLET CODE="DenGen.class" codebase = "build/classes" WIDTH="550" HEIGHT="550" class = applet>
<PARAM NAME = "layers" VALUE = "2">
<PARAM NAME = "nodes" VALUE = "102">
<PARAM NAME = "000" VALUE = "4, 5">
<PARAM NAME = "100" VALUE = "0, 1, 2, 3">
<PARAM NAME = "0" VALUE = "3.52941176471, 158.823529412">
<PARAM NAME = "1" VALUE = "162.352941176, 204.705882353">
<PARAM NAME = "2" VALUE = "208.235294118, 345.882352941">
<PARAM NAME = "3" VALUE = "349.411764706, 360">
</APPLET>
</center>
</body>
</html>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 11 2009
Added on Jul 14 2009
6 comments
226 views