You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Chen Huaping <ch...@hpsgnla.sgp.hp.com> on 2003/07/17 10:48:35 UTC

JSVGComponent exception?

Hi,
There is a exception throw when I load any simple svg file by 
SVGApplication  application.

Anybody can help me?

thanks!


java.lang.ExceptionInInitializerError
        at 
org.apache.batik.swing.svg.JSVGComponent$BridgeUserAgent.getXMLParser
ClassName(JSVGComponent.java:2983)
        at 
org.apache.batik.swing.svg.JSVGComponent$BridgeUserAgentWrapper.getXM
LParserClassName(JSVGComponent.java:2306)
        at 
org.apache.batik.bridge.DocumentLoader.<init>(DocumentLoader.java:66)

        at 
org.apache.batik.swing.svg.JSVGComponent$1.run(JSVGComponent.java:450
)
        at 
org.apache.batik.swing.svg.JSVGComponent.stopThenRun(JSVGComponent.ja
va:642)
        at 
org.apache.batik.swing.svg.JSVGComponent.loadSVGDocument(JSVGComponen
t.java:445)
        at org.apache.batik.swing.JSVGCanvas.setURI(JSVGCanvas.java:459)
        at SVGApplication$2.actionPerformed(SVGApplication.java:57)
        at 
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
64)


import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;

import org.apache.batik.swing.JSVGCanvas;
import org.apache.batik.swing.gvt.GVTTreeRendererAdapter;
import org.apache.batik.swing.gvt.GVTTreeRendererEvent;
import org.apache.batik.swing.svg.SVGDocumentLoaderAdapter;
import org.apache.batik.swing.svg.SVGDocumentLoaderEvent;
import org.apache.batik.swing.svg.GVTTreeBuilderAdapter;
import org.apache.batik.swing.svg.GVTTreeBuilderEvent;

public class SVGApplication {

    public static void main(String[] args) {
        JFrame f = new JFrame("Batik");
        SVGApplication app = new SVGApplication(f);
        f.getContentPane().add(app.createComponents());

        f.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        f.setSize(400, 400);
        f.setVisible(true);
    }
   
    JFrame frame;
    JButton button = new JButton("Load...");
    JLabel label = new JLabel();
    JSVGCanvas svgCanvas = new JSVGCanvas();

    public SVGApplication(JFrame f) {
        frame = f;
    }

    public JComponent createComponents() {
        final JPanel panel = new JPanel(new BorderLayout());

        JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT));
        p.add(button);
        p.add(label);

        panel.add("North", p);
        panel.add("Center", svgCanvas);

        // Set the button action.
        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                JFileChooser fc = new JFileChooser(".");
                int choice = fc.showOpenDialog(panel);
                if (choice == JFileChooser.APPROVE_OPTION) {
                    File f = fc.getSelectedFile();
                    try {
                        svgCanvas.setURI(f.toURL().toString());
                    } catch (IOException ex) {
                        ex.printStackTrace();
                    }
                }
            }
        });

        // Set the JSVGCanvas listeners.
        svgCanvas.addSVGDocumentLoaderListener(new 
SVGDocumentLoaderAdapter() {
            public void documentLoadingStarted(SVGDocumentLoaderEvent e) {
                label.setText("Document Loading...");
            }
            public void documentLoadingCompleted(SVGDocumentLoaderEvent e) {
                label.setText("Document Loaded.");
            }
        });

        svgCanvas.addGVTTreeBuilderListener(new GVTTreeBuilderAdapter() {
            public void gvtBuildStarted(GVTTreeBuilderEvent e) {
                label.setText("Build Started...");
            }
            public void gvtBuildCompleted(GVTTreeBuilderEvent e) {
                label.setText("Build Done.");
                frame.pack();
            }
        });

        svgCanvas.addGVTTreeRendererListener(new GVTTreeRendererAdapter() {
            public void gvtRenderingPrepare(GVTTreeRendererEvent e) {
                label.setText("Rendering Started...");
            }
            public void gvtRenderingCompleted(GVTTreeRendererEvent e) {
                label.setText("");
            }
        });

        return panel;
    }
}



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Batik 1.5 Test.class exception!!

Posted by Chen Huaping <ch...@hpsgnla.sgp.hp.com>.
Hi,
I always get the exception when run the Batik 1.5 Test.class after complile.
Anybody can help me?
the java sdk which I'm using: j2sdk1.4.1_02

java.lang.ExceptionInInitializerError
       at 
org.apache.batik.swing.svg.JSVGComponent$BridgeUserAgent.getXMLParser
ClassName(JSVGComponent.java:2983)
       at 
org.apache.batik.swing.svg.JSVGComponent$BridgeUserAgentWrapper.getXM
LParserClassName(JSVGComponent.java:2306)
..




---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org