To all,

I am trying to use the JSVGCanvas in an application that uses a JDesktopPane
containing several JInternalFrames (one of which contains a JSVGCanvas).
The problem occurs when more than one JInternalFrame exists in the
JDesktopPane.  The behavior is as follows:

If there is a single JInternalFrame (with a JSVGCanvas in it) in the
JDesktopPane, all is well... the SVG graphic appears and can be panned,
zoomed, etc.

If there is more than one JInternalFrame in the JDesktopPane, the
JInternalFrame with the SVGCanvas will display the SVG graphic initially but
as soon as you click the mouse in its frame, the graphic disappears never to
be seen again.

I have attached some code that a previous mailing list user had included as
an example for another problem... the same code can be used to demonstrate
my problem... simply invoke File|New two or more times... you will see the
SVG graphic in the first JInternalFrame but for all other JInternalFrames,
you will not see a graphic... and if you click in the original
JInternalFrame... the graphic will disappear.

Any help would be greatly appreciated,

Fred

package batik.test;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import org.apache.batik.swing.*;
import javax.swing.border.EmptyBorder;
import java.beans.*;

public class BatikFrames {

    private JFrame m_root;
    private JDesktopPane m_desktop;

    public BatikFrames() {
    }

    public void initialize(){
        m_root = new JFrame();
        m_desktop = new JDesktopPane();

        final int inset = 50;
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        m_root.setBounds(inset, inset, screenSize.width - inset*2,
screenSize.height - inset * 2);

        m_root.setJMenuBar(buildMenuBar());
        m_root.getContentPane().add(m_desktop);
        m_root.setVisible(true);
    }

    protected JMenuBar buildMenuBar(){
        JMenuBar menuBar = new JMenuBar();
        JMenu menu = new JMenu("File");
        JMenuItem item = new JMenuItem("New");
        item.addActionListener(
        new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                String url = JOptionPane.showInputDialog(m_root,
                "Enter a URL to an SVG file",
                "Enter URL",
                JOptionPane.QUESTION_MESSAGE);
                addCanvas(url);
            }
        }
        );
        menu.add(item);
        menuBar.add(menu);
        return menuBar;
    }

    protected void addCanvas(String url){
        JInternalFrame internal = new
JInternalFrame(url,true,true,true,true);
        internal.setBounds(10,10,300,400);
        JPanel panel = new JPanel();
        panel.setBorder( new EmptyBorder(5,5,5,5));
        panel.setLayout(new BorderLayout());
        JSVGCanvas canvas = new JSVGCanvas();
        canvas.setURI(url);
        panel.add(canvas, BorderLayout.CENTER);
        internal.getContentPane().add(panel);
        m_desktop.add(internal);
        internal.setVisible(true);
    }

    public static void main(String[] args) {
        BatikFrames batik = new BatikFrames();
        batik.initialize();
    }
}


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to