|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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(); } } |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
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{ ^ |
|
#4
|
||||
|
||||
|
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.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > Programming Tools > help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|