*
The moose likes Swing / AWT / SWT and the fly likes Beginning of the end - reading and writing to a file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Beginning of the end - reading and writing to a file" Watch "Beginning of the end - reading and writing to a file" New topic
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
 
Similar Threads
Is there anyway of overriding the default signal for PopupMenus
Problems moving shapes when set up own Shapes class extending Path2D.Double
Why won't my program draw the line
How does this code work
Finding the endpoint of an Affine Transform