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 Fred Ingham <in...@erols.com> on 2003/07/16 17:06:52 UTC

Problem with multiple JInternalFrame's using batik

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: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


RE: Problem with multiple JInternalFrame's using batik

Posted by Fred Ingham <in...@erols.com>.
Thomas,

I checked out the latest Batik from the CVS repository and the problem with
multiple JInternalFrame(s) is now gone.

Thank you for your assistance,

Fred


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


Re: Problem with multiple JInternalFrame's using batik

Posted by Thomas DeWeese <Th...@Kodak.com>.
Fred Ingham wrote:
> 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:

     What version of Batik? With current CVS I tried your example and it
worked perfectly (well almost if you resized continously for long enough
I would get a stack overflow - but even that is gone now).  I certainly
didn't see anything that sounds like what you describe.

> 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,




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