| Author |
Beginning of the end - reading and writing to a file
|
Kieran Murray
Ranch Hand
Joined: May 18, 2008
Posts: 47
|
|
Dear Ranchers, I can not understand why I am getting this exception when I read in a file. Exception:translation.Generator; translation.Generator; no valid constructor The code to write the object is below The code to read in is Then I repaint the object taken in The paint method is below the Generator class is below [code] package translation; import java.awt.geom.*; import java.awt.Color; import java.awt.Shape; public class Generator extends Shapes{ final String name = "Generator"; Color colour; Path2D.Double shp = new Path2D.Double(); { shp.moveTo(200.0f/5, 220.0f/5); //start point shp.curveTo(130/5, 220/5, 130/5, 320/5, 200/5, 320/5); shp.curveTo(150/5, 260/5, 250/5, 280/5, 200/5, 220/5); shp.moveTo(200.0f/5, 220.0f/5); shp.curveTo(270/5, 220/5, 270/5, 320/5, 200/5, 320/5); shp.lineTo(200.0/5,400.0/5); } public Generator() { } public Path2D.Double getShape() { return shp; } public void setColor(Color colour) { this.colour = colour; } public Color getColour() { return colour; } public String getName() { return this.name; } } Kind regards Kieran
|
 |
Kieran Murray
Ranch Hand
Joined: May 18, 2008
Posts: 47
|
|
Dear Ranchers, I have managed to solve the problem. I changed the Shapes class to an extension of a JComponent rather than an extension of a Path2D.Double. This may have consequences down the line - who knows. I did this after reading the evaluation in this Sun bug database. It talks about Arc2D.Double and I thought this might be applicable to Path2D.Double. http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6522514 Anyway - I did not understand the ins and outs of serialisation - any explanations most welcome. The solution was quick and dirty - but it works . Thanks, Kieran
|
 |
 |
|
|
subject: Beginning of the end - reading and writing to a file
|
|
|