Hi all,
I am trying to use the method setURI from JSVGCanvas, but I can not get it
to work. Please look at source code below and point out what I am doing
wrong.
It seems to be a thread problem. For instance, if I move the
add(m_JSVGCanvas) and showFrame outside the
addSVGLoadEventDispatcherListener, the svg file is rendered.
However, the SVGDocument is null when I try to access it from
JSVGCanvas.getSVGDocument.
Thank you for your help.
Danh Hoai
public EndApplication(){
super("SVG Testing");
try
{
m_JSVGCanvas = new JSVGCanvas();
String fileName = "F:\\svg_collab\\html\\svg\\test.svg";
getSVGFile(fileName); /* get svg file */
m_JSVGCanvas.addSVGLoadEventDispatcherListener
(new SVGLoadEventDispatcherAdapter() {
public void svgLoadEventDispatchStarted
(SVGLoadEventDispatcherEvent e) {
// At this time the document is available...
//getApplicationFrame() returns a JFrame
getApplicationFrame().frame.getContentPane().add(m_JSVGCanvas);
getApplicationFrame().showFrame(); //get current
JFrame and then use method show()
}
}
);
}
}
public SVGDocument getSVGFile(String fileName)
{
SVGOMDocument svgDoc = null;
m_JSVGCanvas.setDocumentState(new
JSVGComponent().ALWAYS_DYNAMIC);
File file = new File(fileName);
try
{
m_JSVGCanvas.setURI(file.toURL().toString());
}
catch (IOException ex)
{
System.out.println("error: ");
ex.printStackTrace();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]