jdic
  1. jdic
  2. JDIC-348

JDIC browser doesn't support heavyweight container hierarchy change

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Blocker Blocker
    • Resolution: Unresolved
    • Affects Version/s: current
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      348

      Description

      The JDIC Browser doesn't support changing its heavyweight ancestor : I'm
      properly posting this issue here as the JDIC forum might not be the best place
      to leave it (I reported the probem there 6 months ago).

      Here's a test case showing the problem with a JFrame and a JDialog, but the
      problem is the same ** when moving from an AWT Panel to another one **.

      This feature is used in VLDocking and probably other docking systems to allow
      embedding the JDIC Browser within lightweight components. It works well with
      other heavywieght components (like JOGL or Open CASCADE 3D renderers) but fails
      with JDIC Browser.

      Best regards,

      Lilian Chamontin, VLSolutions.

      ---------------------------------

      Source Code :

      package test.swing.docking;

      import java.awt.*;
      import java.awt.event.*;
      import java.net.URL;
      import javax.swing.*;
      import org.jdesktop.jdic.browser.WebBrowser;

      /** Test case showing wrong behaviour of WebBrowser when container hierarchy
      change occurs.
      *

      • To reproduce the bug, click on the Detach button. The webbrower will (well,
        should) be detached
      • from its parent frame and put into another window.
        *
      • Here the problem seems to be due to a change of the native parent peer (from a
        jframe to
      • a jdialog).
        *
      • If you move the JDialog you will see the browser moving... inside the JFrame !
        *
      • I have also experimented the same problem when I insert a Panel (awt) in
        between the hierarchy
      • (thus also changing the native parent of the browser).
        *
      • @author Lilian Chamontin, VLSolutions
        */
        public class TestJDIC2 extends JFrame {
        WebBrowser browser;

      JPanel center = new JPanel(new BorderLayout());

      public TestJDIC2() {
      setDefaultCloseOperation(EXIT_ON_CLOSE);
      add(center, BorderLayout.CENTER);
      add(new JLabel("left"), BorderLayout.WEST);
      add(new JLabel("bottom"), BorderLayout.WEST);
      add(new JLabel("right"), BorderLayout.EAST);

      try {
      URL url = new URL("http://www.google.com");

      browser = new WebBrowser(url, false);
      center.add(browser, BorderLayout.CENTER);
      } catch (Exception e){
      e.printStackTrace();
      }

      JButton detach = new JButton("Detach");
      detach.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e)

      { center.remove(browser); JDialog dlg = new JDialog(TestJDIC2.this); dlg.getContentPane().add(browser, BorderLayout.CENTER); dlg.setSize(new Dimension(400,300)); dlg.validate(); dlg.setVisible(true); center.revalidate(); } }); add(detach, BorderLayout.NORTH); center.setPreferredSize(new Dimension(800,600)); pack(); setVisible(true); }

      public static void main(String[] args){
      new TestJDIC2();
      }
      }

        Activity

        Hide
        michael_shan added a comment -

        Hi Lilian,
        Thank you for your reporting.
        At first glance,I don't think it's a webBrowser problem but a problem of Canvas
        or the way we use it.
        A component refer a component then put the refered component into another
        component(though we've removed it,but will it works as we thought?), is that
        operation ok? I'm not sure of that.

        Show
        michael_shan added a comment - Hi Lilian, Thank you for your reporting. At first glance,I don't think it's a webBrowser problem but a problem of Canvas or the way we use it. A component refer a component then put the refered component into another component(though we've removed it,but will it works as we thought?), is that operation ok? I'm not sure of that.
        Hide
        lilianc added a comment -

        Hi Michael,

        The code posted here works fine with any Swing or AWT component, and also works
        with canvases like the GLCanvas from JOGL... There's nothing uncommon in it,
        it's just an AWT component reparenting.

        Reparenting a component (beeing awt or swing) is something found in every
        advanced application (for example, extracting a component from a window to give
        it more room on screen or mergeing two components in a tabbed pane).

        The problem here occurs only if the hierarchy change involves an AWT container
        (Frame, Panel), but works fine with a swing JPanel (e.g. when swapping two
        JSplitPane components).

        Lilian

        Show
        lilianc added a comment - Hi Michael, The code posted here works fine with any Swing or AWT component, and also works with canvases like the GLCanvas from JOGL... There's nothing uncommon in it, it's just an AWT component reparenting. Reparenting a component (beeing awt or swing) is something found in every advanced application (for example, extracting a component from a window to give it more room on screen or mergeing two components in a tabbed pane). The problem here occurs only if the hierarchy change involves an AWT container (Frame, Panel), but works fine with a swing JPanel (e.g. when swapping two JSplitPane components). Lilian
        Hide
        michael_shan added a comment -

        Hi,
        Change "browser = new WebBrowser(url, false)"; to "browser = new WebBrowser(url,
        true);"
        Pls refer the javadoc :
        /**

        • Constructs a new <code>WebBrowser</code> with an specified URL and
        • boolean flag to indicate the dispose schema.
        • @param url
        • the URL to be shown in this instance.
        • @param autoDispose
        • ture to indicate this instance will automatically dispose
        • itself in <code>removeNotify()</code>; false to indicate
        • the developer should call <code>dispose()</code> when this
        • instance is no longer needed.
        • @see #removeNotify()
        • @see #dispose()
        • @see #isAutoDispose()
          */
          public WebBrowser(URL url, boolean autoDispose) {........}
        Show
        michael_shan added a comment - Hi, Change "browser = new WebBrowser(url, false)"; to "browser = new WebBrowser(url, true);" Pls refer the javadoc : /** Constructs a new <code>WebBrowser</code> with an specified URL and boolean flag to indicate the dispose schema. @param url the URL to be shown in this instance. @param autoDispose ture to indicate this instance will automatically dispose itself in <code>removeNotify()</code>; false to indicate the developer should call <code>dispose()</code> when this instance is no longer needed. @see #removeNotify() @see #dispose() @see #isAutoDispose() */ public WebBrowser(URL url, boolean autoDispose) {........}
        Hide
        lilianc added a comment -

        The problem is that the browser shoudn't be auto-disposed !

        If the user is in the middle of filling a form, the form will be cleared when
        changing of parent (the page is reloaded) : this is unacceptable for our
        customers...

        (and if some applets are running in the web page, they will be destroyed as well).

        Show
        lilianc added a comment - The problem is that the browser shoudn't be auto-disposed ! If the user is in the middle of filling a form, the form will be cleared when changing of parent (the page is reloaded) : this is unacceptable for our customers... (and if some applets are running in the web page, they will be destroyed as well).
        Hide
        michael_shan added a comment -

        Assign to Michael.

        Show
        michael_shan added a comment - Assign to Michael.

          People

          • Assignee:
            michael_shan
            Reporter:
            lilianc
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: