Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 5th, 2004, 02:43 PM
Harryortho Harryortho is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 6 Harryortho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy help i get invalid code and the errors will show on the next post

here is the code with the error messages on the bottom, any help??
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class GraphDisplayScrollbars extends Applet implements AdjustmentListener{
int height = 250;
int width = 300;

int leftMargin = 40;
int rightMargin = 40;
int topMargin = 40;
int bottomMargin = 40;

double xmin = 0;
double xmax = 10;
double ymin = -10;
double ymax = 10;

double a;
double b;
double c;
double d;

private Scrollbar sliderA;
private int sliderAValue = 0;

private Scrollbar sliderB;
private int sliderBValue = 0;

private Scrollbar sliderC;
private int sliderCValue = 0;

private Scrollbar sliderD;
private int sliderDValue = 0;

public void init() {

Label A, B, C, D;

A = new Label("A");
add(A);

sliderA = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, 50);
add(sliderA);
sliderA.addAdjustmentListener(this);

B = new Label("B");
add(B);
sliderB = new Scrollbar(Scrollbar.VERTICAL, 0, 1 0, 50);
add(sliderB);
sliderB.addAdjustmentListener(this);

C = new Label("C");
add(C);
sliderC = new Scrollbar(Scrollbar.VERTICAL, 0, 1, 0, 50);
add(sliderC);
sliderC.addAdjustmentListener(this);

D = new Label ("D");
add(D);
sliderD = new Scrollbar(Scrollbar.VERTICAL, 0, 1, 0, 100);
add(sliderD);
sliderD.addAdjustmentListener(this);
}

public void paint(Graphics g) {
g.drawLine(scaleX(xmin), scaleY(ymin), scaleX(xmax), scaleY(ymin));
g.drawLine(scaleX(xmin), scaleY(ymin), scaleX(xmin), scaleY(ymax));
g.drawString(" A = " + sliderAValue, 50, 240);
g.drawString(" B = " + sliderBValue, 70, 240);
g.drawString(" C = " + sliderCValue, 90, 240);
g.drawString(" D = " + sliderDValue, 110, 240);
double x, y;
double xlast = xmin;
double ylast = funct(xmin, a, b, c, d);

for (int i=0; i<100; i++){
x = xmin + i*(xmax-xmin)/100.0;
y = funct(x, a, b, c, d);
if (x >= xmin && x <=xmax && y >= ymin && y <= ymax) {
g.drawLine(scaleX(xlast), scaleY(ylast), scaleX(x), scaleY(y));
}
xlast = x;
ylast = y;
}
}
private int scaleX(double x) {
double xRange = xmax - xmin;
int pixelRange = width - leftMargin - rightMargin;
int pixelX = leftMargin + (int) Math.round ((x-xmin)*pixelRange/xRange);
return pixelX;
}
private int scaleY(double y) {
double yRange = ymax - ymin;
int pixelRange = height - topMargin - bottomMargin;
int pixelY = topMargin + (int) Math.round((ymax - y)*pixelRange/yRange);
return pixelY;
}
private double funct(double x, double a, double b, double c, double d){
return a + x*b + Math.pow(x,2)*c + Math.pow(x,3)*d;
}
public void adjustmentValueChanged(AdjustmentEvent e) {
sliderAValue = sliderA.getValue();
sliderBValue = sliderB.getValue();
sliderCValue = sliderC.getValue();
sliderDValue = sliderD.getValue();
repaint();
}
}

Reply With Quote
  #2  
Old March 5th, 2004, 02:45 PM
Harryortho Harryortho is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 6 Harryortho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
here is the error message

Compiling GraphDisplayScrollbars.java...
GraphDisplayScrollbars.java:42: illegal character: \160



^

GraphDisplayScrollbars.java:42: illegal character: \160



^

GraphDisplayScrollbars.java:42: illegal character: \160



^

GraphDisplayScrollbars.java:42: illegal character: \160



^

GraphDisplayScrollbars.java:42: illegal character: \160



^

GraphDisplayScrollbars.java:42: illegal character: \160



^

GraphDisplayScrollbars.java:42: illegal character: \160



^

GraphDisplayScrollbars.java:42: illegal character: \160



^

GraphDisplayScrollbars.java:42: illegal character: \160



^

GraphDisplayScrollbars.java:42: illegal character: \160



^

GraphDisplayScrollbars.java:42: illegal character: \160



^

11 errors

Done.

Reply With Quote
  #3  
Old March 5th, 2004, 04:04 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Moved this to the java forum rather than the javascript forum. Big difference.

Which line is 42?
__________________
Please don't PM me asking for solutions outside the scope of a thread.
Keeping all responses in a thread stands to help others who come along later,
which is after all what this forum's all about.

Reply With Quote
  #4  
Old March 5th, 2004, 04:47 PM
Harryortho Harryortho is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 6 Harryortho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
this is what i get

import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class GraphDisplayScrollbars extends Applet implements AdjustmentListener{
int height = 250;
int width = 300;

int leftMargin = 40;
int rightMargin = 40;
int topMargin = 40;
int bottomMargin = 40;

double xmin = 0;
double xmax = 10;
double ymin = -10;
double ymax = 10;

double a;
double b;
double c;
double d;

private Scrollbar sliderA;
private int sliderAValue = 0;

private Scrollbar sliderB;
private int sliderBValue = 0;

private Scrollbar sliderC;
private int sliderCValue = 0;

private Scrollbar sliderD;
private int sliderDValue = 0;

public void init() {
// Label A, B, C, D;
Label Aa = new Label("A");
add(Aa);
sliderA = new Scrollbar(Scrollbar.VERTICAL, 0, 1, 0, 50);
add(sliderA);
sliderA.addAdjustmentListener(this);

Label Ba = new Label("B");
add(Ba);
sliderB = new Scrollbar(Scrollbar.VERTICAL, 0, 1, 0, 50);
add(sliderB);
sliderB.addAdjustmentListener(this);

Label Ca = new Label("C");
add(Ca );
sliderC = new Scrollbar(Scrollbar.VERTICAL, 0, 1, 0, 50);
add(sliderC);
sliderC.addAdjustmentListener(this);

Label Da = new Label ("D");
add(Da);
sliderD = new Scrollbar(Scrollbar.VERTICAL, 0, 1, 0, 100);
add(sliderD);
sliderD.addAdjustmentListener(this);
}

public void paint(Graphics g) {
g.drawLine(scaleX(xmin), scaleY(ymin), scaleX(xmax), scaleY(ymin));
g.drawLine(scaleX(xmin), scaleY(ymin), scaleX(xmin), scaleY(ymax));
g.drawString(" A = " + sliderAValue, 50, 240);
g.drawString(" B = " + sliderBValue, 70, 240);
g.drawString(" C = " + sliderCValue, 90, 240);
g.drawString(" D = " + sliderDValue, 110, 240);
double x, y;
double xlast = xmin;
double ylast = funct(xmin, a, b, c, d);

for (int i=0; i<100; i++){
x = xmin + i*(xmax-xmin)/100.0;
y = funct(x, a, b, c, d);
if (x >= xmin && x <=xmax && y >= ymin && y <= ymax) {
g.drawLine(scaleX(xlast), scaleY(ylast), scaleX(x), scaleY(y));
}
xlast = x;
ylast = y;
}
}
private int scaleX(double x) {
double xRange = xmax - xmin;
int pixelRange = width - leftMargin - rightMargin;
int pixelX = leftMargin + (int) Math.round ((x-xmin)*pixelRange/xRange);
return pixelX;
}
private int scaleY(double y) {
double yRange = ymax - ymin;
int pixelRange = height - topMargin - bottomMargin;
int pixelY = topMargin + (int) Math.round((ymax - y)*pixelRange/yRange);
return pixelY;
}
private double funct(double x, double a, double b, double c, double d){
return a + x*b + Math.pow(x,2)*c + Math.pow(x,3)*d;
}
public void adjustmentValueChanged(AdjustmentEvent e) {
sliderAValue = sliderA.getValue();
sliderBValue = sliderB.getValue();
sliderCValue = sliderC.getValue();
sliderDValue = sliderD.getValue();
repaint();
}
}


and this is what the compliler sais
Building Project...
Compiling Graph1.java...
Graph1.java:39: illegal character: \160

add(Aa);

^

Graph1.java:39: illegal character: \160

add(Aa);

^

Graph1.java:39: illegal character: \160

add(Aa);

^

Graph1.java:39: illegal character: \160

add(Aa);

^

Graph1.java:39: illegal character: \160

add(Aa);

^

Graph1.java:39: illegal character: \160

add(Aa);

^

Graph1.java:39: illegal character: \160

add(Aa);

^

Graph1.java:39: illegal character: \160

add(Aa);

^

Graph1.java:39: illegal character: \160

add(Aa);

^

Graph1.java:39: illegal character: \160

add(Aa);

^

Graph1.java:58: illegal character: \160

sliderD = new Scrollbar(Scrollbar.VERTICAL, 0, 1, 0, 100);

^

Graph1.java:58: ')' expected

sliderD = new Scrollbar(Scrollbar.VERTICAL, 0, 1, 0, 100);

^

Graph1.java:5: class GraphDisplayScrollbars is public, should be declared in a file named GraphDisplayScrollbars.java

public class GraphDisplayScrollbars extends Applet implements AdjustmentListener{

^

13 errors

Done.
Done.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > help i get invalid code and the errors will show on the next post


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT