Programming Tools
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingProgramming Tools

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, 04:44 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
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, 04:49 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
help-errors

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:59 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
errors

Graph1.java:41: illegal character: \160

add(A);

^

Graph1.java:41: illegal character: \160

add(A);

^

Graph1.java:41: illegal character: \160

add(A);

^

Graph1.java:41: illegal character: \160

add(A);

^

Graph1.java:41: illegal character: \160

add(A);

^

Graph1.java:41: illegal character: \160

add(A);

^

Graph1.java:41: illegal character: \160

add(A);

^

Graph1.java:41: illegal character: \160

add(A);

^

Graph1.java:41: illegal character: \160

add(A);

^

Graph1.java:41: illegal character: \160

add(A);

^

Graph1.java:60: illegal character: \160

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

^

Graph1.java:60: ')' 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{

^

Reply With Quote
  #4  
Old March 5th, 2004, 06:57 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Harryortho - please ONLY post the code with the erros, and any other code you think might be causing the problem. Also please write your description of the post at the top. Please read the rules before posting again.
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingProgramming Tools > help


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 4 hosted by Hostway
Stay green...Green IT