Skip to main content

JDIC WebBrowser Init Problem in JApplet

24 replies [Last post]
philabuster
Offline
Joined: 2006-07-06

I'm can't get the JDIC WebBrowser component to initialize properly in my JApplet.

=============
Configuration:

JDIC WebBrowser version 20060613
JDK 1.5.0_06 / NetBeans 5.0
Windows XP
Swing MDI type applet

The WebBrowser exists in the following hierarchy:

JApplet/JDesktopPane/JInternalFrame/JTabbedPane/JScrollPan

===============

The browser appears as a gray area in the first tab. If I select another tab and then re-select the webbrowser tab via a mouse-click or keyboard tab, the webbrowser will initialize properly.

If the webbrowser doesn't initialize, then the application can't quit, and any change of focus will cause the application to hang.

Also, after successful initialization (via the tabs), a change of focus from the webbrowser to another jInternalFrame and back again will cause the webbrowser component to re-initialize losing all state information. I work around this problem by remembering the webbrowser state which I restore via the initialize event.

I have not found a workaround for the applet startup initialization problem but I have attempted all sorts of strategies involving invokeLater focus changes, component change of state monitoring. One thing to note is that requestFocusInWindow() returns false - basically because the webbrowser hasn't initialized.

With webbrowser debug set, there is a small amount of activity during applet startup, but no webbrowser initialization complete event is received:

=================
*** Jtrace: Found a free socket port: 3075
native lib path C:\Documents and Settings\RasterAD_dev\My Documents\My Projects\java\jdic-20060613-bin-windows\windows*** Jtrace: nspr4.dll under C:\Documents and Settings\RasterAD_dev\My Documents\My Projects\java\jdic-20060613-bin-windows\windows\ielib is set to PATH
*** Jtrace: Engine initialize once!
native lib path C:\Documents and Settings\RasterAD_dev\My Documents\My Projects\java\jdic-20060613-bin-windows\windows*** Jtrace: Executing C:\Documents and Settings\RasterAD_dev\My Documents\My Projects\java\jdic-20060613-bin-windows\windows\IeEmbed.exe -port=3075
*** Jtrace: Connecting to native browser ... 0
*** Jtrace: connected
*** Jtrace: Process event to native browser: 0, 0,
*** Jtrace: Send data to socket: 0,0,
============

When another tab is clicked and then the webbrowser tab is clicked, the webbrowser initializes and an initialization complete event is received. The applet performs several webbrowser transactions and the following debug trace is seen:

============
*** Jtrace: Process event to native browser: 0, 1,
*** Jtrace: Send data to socket: 0,1,4720898
*** Jtrace: Read data from socket: 0,30420,30030,3022,back=00,3022,forward=00,3024,Opening page about:blank...0,3022,back=00,3022,forward=00,3023,XYZ - Engineering a Better World through Science , Technology and Innovation.0,30040,3024,Done0,30050,3023,about:blank0,3005
*** Jtrace: Got a complete short message: 0,3042
*** Jtrace: Process event from native browser: 0, 3042, null
*** Jtrace: Dispatch event from NativeEventThread: 3042
webBrowser initializationCompleted
*** Jtrace: Process event to native browser: 0, 4,
*** Jtrace: Send data to socket: 0,4,0,0,488,475
*** Jtrace: Got a complete short message: 0,3003
*** Jtrace: Process event from native browser: 0, 3003, null
*** Jtrace: Process event to native browser: 0, 4,
*** Jtrace: Send data to socket: 0,4,0,0,491,478
*** Jtrace: Got a complete short message: 0,3022,back=0
*** Jtrace: Process event from native browser: 0, 3022, back=0
*** Jtrace: Process event to native browser: 0, 17,
*** Jtrace: Send data to socket: 0,17,navigator.userAgent
*** Jtrace: Got a complete short message: 0,3022,forward=0
*** Jtrace: Process event from native browser: 0, 3022, forward=0
*** Jtrace: Got a complete short message: 0,3024,Opening page about:blank...
*** Jtrace: Process event from native browser: 0, 3024, Opening page about:blank...
*** Jtrace: Got a complete short message: 0,3022,back=0
*** Jtrace: Process event from native browser: 0, 3022, back=0
*** Jtrace: Got a complete short message: 0,3022,forward=0
*** Jtrace: Process event from native browser: 0, 3022, forward=0
*** Jtrace: Got a complete short message: 0,3023,XYZ - Engineering a Better World through Science , Technology and Innovation.
*** Jtrace: Process event from native browser: 0, 3023, XYZ - Engineering a Better World through Science , Technology and Innovation.
*** Jtrace: Read data from socket: 0,30040,3024,Done0,30050,3023,about:blank0,30050,3024,Done0,3024,Done0,3063,Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
*** Jtrace: Got a complete short message: 0,3004
*** Jtrace: Process event from native browser: 0, 3004, null
*** Jtrace: Got a complete short message: 0,3024,Done
*** Jtrace: Process event from native browser: 0, 3024, Done
*** Jtrace: Got a complete short message: 0,3005
*** Jtrace: Process event from native browser: 0, 3005, null
*** Jtrace: Got a complete short message: 0,3023,about:blank
*** Jtrace: Process event from native browser: 0, 3023, about:blank
*** Jtrace: Got a complete short message: 0,3005
*** Jtrace: Process event from native browser: 0, 3005, null
*** Jtrace: Got a complete short message: 0,3024,Done
*** Jtrace: Process event from native browser: 0, 3024, Done
*** Jtrace: Got a complete short message: 0,3024,Done
*** Jtrace: Process event from native browser: 0, 3024, Done
*** Jtrace: Got a complete short message: 0,3063,Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
*** Jtrace: Process event from native browser: 0, 3063, Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
*** Jtrace: Process event to native browser: 0, 17,
*** Jtrace: Send data to socket: 0,17,navigator.appVersion
*** Jtrace: Read data from socket: 0,3063,4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
*** Jtrace: Got a complete short message: 0,3063,4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
*** Jtrace: Process event from native browser: 0, 3063, 4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
loadStartingPage()
*** Jtrace: Process event to native browser: 0, 16,
*** Jtrace: Send data to socket: 0,16,
*** Jtrace: Dispatch event from NativeEventThread: 3003
*** Jtrace: Dispatch event from NativeEventThread: 3022
*** Jtrace: Back State changed = false
*** Jtrace: Dispatch event from NativeEventThread: 3022
*** Jtrace: Forward State changed = false
*** Jtrace: Dispatch event from NativeEventThread: 3024
*** Jtrace: Dispatch event from NativeEventThread: 3022
*** Jtrace: Back State changed = false
*** Jtrace: Dispatch event from NativeEventThread: 3022
*** Jtrace: Forward State changed = false
*** Jtrace: Dispatch event from NativeEventThread: 3023
*** Jtrace: Process event to native browser: 0, 17,
*** Jtrace: Send data to socket: 0,17,if(typeof java_get_event == "function") java_get_event();
*** Jtrace: Read data from socket: 0,3024,Done0,30030,30040,3024,Done0,30050,3023,about:blank0,30050,30070,30630,3024,Done0,3024,Done
*** Jtrace: Got a complete short message: 0,3024,Done
*** Jtrace: Process event from native browser: 0, 3024, Done
*** Jtrace: Got a complete short message: 0,3003
*** Jtrace: Process event from native browser: 0, 3003, null
*** Jtrace: Got a complete short message: 0,3004
*** Jtrace: Process event from native browser: 0, 3004, null
*** Jtrace: Got a complete short message: 0,3024,Done
*** Jtrace: Process event from native browser: 0, 3024, Done
*** Jtrace: Got a complete short message: 0,3005
*** Jtrace: Process event from native browser: 0, 3005, null
*** Jtrace: Got a complete short message: 0,3023,about:blank
*** Jtrace: Process event from native browser: 0, 3023, about:blank
*** Jtrace: Got a complete short message: 0,3005
*** Jtrace: Process event from native browser: 0, 3005, null
*** Jtrace: Got a complete short message: 0,3007
*** Jtrace: Process event from native browser: 0, 3007, null
*** Jtrace: Got a complete short message: 0,3063
*** Jtrace: Process event from native browser: 0, 3063, null
*** Jtrace: Dispatch event from NativeEventThread: 3004
*** Jtrace: Dispatch event from NativeEventThread: 3024
*** Jtrace: Dispatch event from NativeEventThread: 3005
*** Jtrace: Dispatch event from NativeEventThread: 3023
*** Jtrace: Got a complete short message: 0,3024,Done
*** Jtrace: Process event from native browser: 0, 3024, Done
*** Jtrace: Process event to native browser: 0, 17,
*** Jtrace: Send data to socket: 0,17,if(typeof java_get_event == "function") java_get_event();
*** Jtrace: Got a complete short message: 0,3024,Done
*** Jtrace: Process event from native browser: 0, 3024, Done
*** Jtrace: Read data from socket: 0,3063
*** Jtrace: Got a complete short message: 0,3063
*** Jtrace: Process event from native browser: 0, 3063, null
*** Jtrace: Dispatch event from NativeEventThread: 3005
*** Jtrace: Dispatch event from NativeEventThread: 3024
*** Jtrace: Dispatch event from NativeEventThread: 3024
*** Jtrace: Dispatch event from NativeEventThread: 3024
*** Jtrace: Dispatch event from NativeEventThread: 3003
*** Jtrace: Dispatch event from NativeEventThread: 3004
*** Jtrace: Dispatch event from NativeEventThread: 3024
*** Jtrace: Dispatch event from NativeEventThread: 3005
*** Jtrace: Dispatch event from NativeEventThread: 3023
*** Jtrace: Process event to native browser: 0, 17,
*** Jtrace: Send data to socket: 0,17,if(typeof java_get_event == "function") java_get_event();
*** Jtrace: Read data from socket: 0,3063
*** Jtrace: Got a complete short message: 0,3063
*** Jtrace: Process event from native browser: 0, 3063, null
*** Jtrace: Dispatch event from NativeEventThread: 3005
*** Jtrace: Dispatch event from NativeEventThread: 3007
*** Jtrace: Process event to native browser: 0, 17,
*** Jtrace: Send data to socket: 0,17,if(typeof java_get_dom == "function") java_get_dom();
*** Jtrace: Read data from socket: 0,3063
*** Jtrace: Got a complete short message: 0,3063
*** Jtrace: Process event from native browser: 0, 3063, null
*** Jtrace: Process event to native browser: 0, 17,
*** Jtrace: Send data to socket: 0,17,if(typeof java_get_dom_buffer == "function") java_get_dom_buffer();
*** Jtrace: Read data from socket: 0,3063
*** Jtrace: Got a complete short message: 0,3063
*** Jtrace: Process event from native browser: 0, 3063, null
*** Jtrace: Process event to native browser: 0, 17,
*** Jtrace: Send data to socket: 0,17,if(typeof webview_init == "function") webview_init();
*** Jtrace: Read data from socket: 0,3063
*** Jtrace: Got a complete short message: 0,3063
*** Jtrace: Process event from native browser: 0, 3063, null
*** Jtrace: Dispatch event from NativeEventThread: 3024
*** Jtrace: Dispatch event from NativeEventThread: 3024
============

The webbrowser has the well-known Z-order problem associated with Swing light-weight / AWT heavy-weight mixing. In an adjoining JTree component's JPopupMenu, I have noticed erratic behavior. During some applet runs I noticed that the popup positioned itself to avoid a Z-order mishap, but I haven't been able to find out how to make it work properly.

Any help to solve the above problems would be greatly appreciated.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
michael_shan
Offline
Joined: 2005-05-29

Hi,

Please refer my former post,mentioned all of there.

> > I haven't been totally successful with the
> > workarounds as you will see and I don't like the
> > flashs seen during webbrowser restoration etc. I
> > would like a real solution where I don't need
> > workarounds.
> These are not workarounds but necessary and right
> things you have to do,and further, you need provide
> more "workarounds" like these(I'll show you some).
> Why JDIC need use these "workarounds"? In fact, it's
> not JDIC, but when develop Java GUI,especially when
> you mix swing and awt. I strongly suggest you read
> the url I've post about mixing issues. Some problems
> have a long history, we have to use some tips to
> realized our apps, they are really necessary.
>
> > 1. You can make the webbrowser initialize by
> clicking
> > on "Another View" tab then back on the "WebBrowser
> > Tab".
> > 2. If the webbrowser isn't initialized, the
> applet
> > hangs when you try to close it.
>
[b]> As I said, this an awt Canvas bug, mustang has fixed
> it.
> You can change your jre to mustang or use some
> workarouds I've post.
> [/b]
> > 3. Minimizing/Iconifying and restoring the
> webbrowser
> > JInternalFrame causes the applet to hang.
[b]> Can't reproduce it.[/b]
>
> > 4. Resizing the webbrowser JInternalFrame by
> dragging
> > a corner larger and then smaller will leave the
> > webbrowser pane hanging in the larger size - not
> > obeying its container.
[b]> This maybe a bug, the web browser seems have a
> minimum width and can't be reduced when arrive that.[/b]
>
> > 5. If you drag the left JInternalFrame across the
> > webbrowser pane, it is covered due to the Z-order
> > problem.
[b]> This is the famous "Z-order" problem. We still don't
> know how to fix it. Many docs suggest don't mix it
> with Canvas.[/b]
>
> > 6. Doing a "Unit Tests"/"Test Navigate", followed
> by
> > a click refocus on the left JInternaFrame and then
> a
> > click refocus back onto the webbrowser
> JInternalFrame
> > will leave the webbrowser pane blank; however,
> > slightly resize the webbrowser JInternalFrame by
> > dragging on its boundary and it will reappear.
[b]> Can't reproduce it.[/b]
>
> > ... too many little things to mention here - look
> for
> > yourself.
>
[b]> Here are more tips:
> 1. When the internal frame is
> Minimizing/Iconifying,hide the web browser.
> 2. When the internal frame is active, set web browser
> to visible and resize web browser's size according
> the internal frame's .
> 3. When the internal frame is closed, dispose web
> browser.
> [/b]

> thanks,
> Michael

michael_shan
Offline
Joined: 2005-05-29

Hi,
I'm not sure if you have read Funkyidol's code,he has given a better workaroud (if you don't want to migrate to Mustang),below are some details, thank you Funkyidol!

"Hi Funkyidol,
Thank you for your code.As a result, the part"java.awt.EventQueue.invokeLater" can fix this issue. JDIC is initialized in a thread, but for some reason, the thread can't be always succssfully finished(pending there for some events but failed to be invoked again I guess). While as invokerLater's comments said "This will happen after all pending events are processed",and it really works well. Thanks again!"

Michael

philabuster
Offline
Joined: 2006-07-06

funkyidol's code is not a JApplet and is not built on top of JDesktopPane/JInternalFrame. Consequently, his workarounds don't work for me.

Did you try to run the java applet I provided?

You stated that:

> > 3. Minimizing/Iconifying and restoring the
> webbrowser
> > JInternalFrame causes the applet to hang.
> Can't reproduce it.

> > 6. Doing a "Unit Tests"/"Test Navigate", followed
> by
> > a click refocus on the left JInternaFrame and then
> a
> > click refocus back onto the webbrowser
> JInternalFrame
> > will leave the webbrowser pane blank; however,
> > slightly resize the webbrowser JInternalFrame by
> > dragging on its boundary and it will reappear.
> Can't reproduce it.

I would like to understand why you have a different result. What is your configuration when running my test code?

FYI, I imported and tested funkyidol's code - before making any comments.

First of all funkyidol must have been using an earlier version of WebBrowser because his code is missing:

public void initializationCompleted(WebBrowserEvent event)
{
}

funkyidol's WebBrowser component initialized under an Application/JFrame configuration. But this configuration is one of several typical configurations that has workarounds.

What about my configuration? Did you test it?

michael_shan
Offline
Joined: 2005-05-29

You are right. I've tried funkyidol's code, it doesn't work for your applet :(.

While I've ran your code with Mustang jre,it does work well for JTabbed/Panel/Canvas(JDIC) initialization issue.

Why don't have a try of mustang?Get it from http://download.java.net/jdk6/binaries/ and have a try.

bagyaraj
Offline
Joined: 2008-09-19

Hi Machel,

I'm using JDIC(Web browser) to display a pdf file in the JDialog, it's displaying very fine. But after closing the dialog web brower reference not cleared(i.e able to view running process in task manager). Adobe reference window displayed while shutdown the machine and it indicates one or more web browser reference is available.

Please could tell me how to clear the adobe reference while closing dialog.

I have tried to destroy method in web browser but it is not working.

Thanks and Regards,

Bagy

michael_shan
Offline
Joined: 2005-05-29

> I haven't been totally successful with the
> workarounds as you will see and I don't like the
> flashs seen during webbrowser restoration etc. I
> would like a real solution where I don't need
> workarounds.
These are not workarounds but necessary and right things you have to do,and further, you need provide more "workarounds" like these(I'll show you some). Why JDIC need use these "workarounds"? In fact, it's not JDIC, but when develop Java GUI,especially when you mix swing and awt. I strongly suggest you read the url I've post about mixing issues. Some problems have a long history, we have to use some tips to realized our apps, they are really necessary.

> 1. You can make the webbrowser initialize by clicking
> on "Another View" tab then back on the "WebBrowser
> Tab".
> 2. If the webbrowser isn't initialized, the applet
> hangs when you try to close it.

As I said, this an awt Canvas bug, mustang has fixed it.
You can change your jre to mustang or use some workarouds I've post.

> 3. Minimizing/Iconifying and restoring the webbrowser
> JInternalFrame causes the applet to hang.
Can't reproduce it.

> 4. Resizing the webbrowser JInternalFrame by dragging
> a corner larger and then smaller will leave the
> webbrowser pane hanging in the larger size - not
> obeying its container.
This maybe a bug, the web browser seems have a minimum width and can't be reduced when arrive that.

> 5. If you drag the left JInternalFrame across the
> webbrowser pane, it is covered due to the Z-order
> problem.
This is the famous "Z-order" problem. We still don't know how to fix it. Many docs suggest don't mix it with Canvas.

> 6. Doing a "Unit Tests"/"Test Navigate", followed by
> a click refocus on the left JInternaFrame and then a
> click refocus back onto the webbrowser JInternalFrame
> will leave the webbrowser pane blank; however,
> slightly resize the webbrowser JInternalFrame by
> dragging on its boundary and it will reappear.
Can't reproduce it.

> ... too many little things to mention here - look for
> yourself.

Here are more tips:
1. When the internal frame is Minimizing/Iconifying,hide the web browser.
2. When the internal frame is active, set web browser to visible and resize web browser's size according the internal frame's .
3. When the internal frame is closed, dispose web browser.

> I saw several issues that were similar but I don't
> believe the problem is as simple as stated.
Yes, you have to provide "workarouds" for your complicate app.Many issues are introduced by mixing of swing and awt.

thanks,
Michael

michael_shan
Offline
Joined: 2005-05-29

As http://bugs.sun.com/bugdatabase/view_bug.do;:YfiG?bug_id=4154448 shows, the "Heavy Implementation JInternalFrame " is still not available.

funkyidol
Offline
Joined: 2006-06-19

i have made a java app that utilizes JDIC webBrowser within a tabbed interface..
the hierarchy is as follows
JPanel->tabbedPane->Jpanel->jscrollPane->webBrowser
and things are working perfectly for me...
including the tab switch with no exception as such...
for others having similar issues, i can post my code if required...
I had certain issues with the scrollPane though but they were solved in the below post
http://forums.java.net/jive/thread.jspa?threadID=16718&tstart=0

philabuster
Offline
Joined: 2006-07-06

I tried a couple of configurations:

1. JApplet->JPanel->JTabbedPane->JPanel->JScrollPane->WebBrowser.

2. JApplet->JDesktopPane->JInternalFrame->JPanel->JTabbedPane->JPanel->JScrollPane->WebBrowser

neither worked for me.

My current project requires an MDI hierarchy as follows:

JApplet->JDesktopPane->JInternalFrame->JTabbedPane->JScrollPane->WebBrowser

or possibly a workaround hierarchy of the following form (if one exists):

JApplet->JDesktopPane->JInternalFrame->(workaround)->JTabbedPane->(workaround)->JScrollPane->(workaround)->WebBrowser.

So far I haven't seen a workaround hierarchy that fixes the WebBrowser issues.

funkyidol
Offline
Joined: 2006-06-19

as i posted earlier im using the first configuration that u mentioned but i have a Jframe instead of Japplet. and it work fine with me..

i was also having issues while using JInternalFrame and JDesktopPane...but they were more or less bug in netbeans..

u could try to initialize the things
in the follong manner...it might help..atleast it worked for me
WebBrowser webBrowser=new WebBrowser();
JScrollPane scroll= new JScrollPane(webBrowser);

instead of adding with component.add(component) method.

philabuster
Offline
Joined: 2006-07-06

There are many component hierarchies that work with WebBrowser; unfortunately, there are also many that don't.

You are using one of the application hierarchies that work. I am using one of the applet hierarchies that is broken. The trouble is that there is no consistent set of workarounds for all hierarchies.

After doing extensive research regarding workarounds for the JDIC WebBrowser I tested and incorporated all working contributions and invented a couple of my own, but many problems persist. If you look at the code that I submitted earlier in this posting, you will see that I used initialization similar to what you are suggesting:

jScrollPane_webbrowser = new JScrollPane(webBrowser.asComponent());

This does not solve the initialization problem.

In addition, I have tried countless other tricks and permutations to try to force the WebBrowser component to initialize or repaint - all without success. For example, I tried to use a JLayeredPane to simulate a JTabbedPane. Although the WebBrowser component initialized, it would not repaint when it's Z-order was taken out of view and moved back to the front again.

The central issue to me is that the WebBrowser component will not work in a number of hierarchies and my current project requires that I use one of the broken hierarchies.

It is of some concern to me that problems with the WebBrowser may be tied to a bug reported against Canvas back in 1998. Wasn't this fixed and tested? It would seem to me that only superficial testing is being performed on this software.

On the other hand, I am happy to see that Michael Shan is looking into the root causes for these WebBrowser issues and may find a solution that makes all our development efforts easier.

I hope that the goal of the JDIC team would be to
make the WebBrowser work in all hierarchies without workaraounds. This would save countless people from spending countless days trying all possible permutations of workarounds. On this one issue I have spent several weeks of effort - jeopardizing my project. If the WebBrowser had worked as expected my development effort would have been just a few minutes.

michael_shan
Offline
Joined: 2005-05-29

Hi,
Mixing of awt/swing component isn't a very easy topic in my opinion and we JDIC let you guys have to meet this,since we have to embed a native window. What I'm doing now is to find out more workaourds that could let JDIC work well with swing and tell them to users to use, but not to let it work without workarounds.

philabuster
Offline
Joined: 2006-07-06

I haven't seen much activity on this topic. Are you still trying to find workarounds?

michael_shan
Offline
Joined: 2005-05-29

Hi,
Some updates on this issue.

- The JTabbedPane will cause JDIC can't initialize completely only when the tab is switched.
WebBrowser runs in thread model, seems that the thread is paused, and web browser's pait() method is not called.Only when you switch the tab, it will go on working.

A simple code can reproduce it:
/*
* Created on 2006-1-11
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package jdiccr;

/**
* @author syl
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.net.MalformedURLException;
import java.net.URL;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

import org.jdesktop.jdic.browser.WebBrowser;

/**
* WebBrowser component in JTabbedPane shows up even its tab is not selected.
* Defect only with JDK 1.4.2. Works correct on JDK5.
*/
public class JTabbedPaneTest {
private WebBrowser webBrowser;

public JTabbedPaneTest() {

JPanel p1 = new JPanel();
p1.setBackground(Color.GREEN);

JPanel p2 = new JPanel(new BorderLayout());
WebBrowser.setDebug(true);
webBrowser = new WebBrowser();
p2.add(webBrowser);

JTabbedPane tab = new JTabbedPane();
tab.add("1", p2);
tab.add("2", p1);

JFrame frame = new JFrame("JDIC Browser test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(tab);
frame.setBounds(0, 0, 640, 480);
frame.setVisible(true);

webBrowser.setContent("Content of Tab #2"
+ " (Tab #1 is EMPTY!)");
URL url;
try {
url = new URL("http://www.java.sun.com");
webBrowser.setURL(url);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

public static void main(String[] args) throws Exception {
new JTabbedPaneTest();
}
}
- JInternaleFrame's z-order issue.
This is a known issue, we still don't good way to fix it.

thanks,
Michael

simonmcmahon
Offline
Joined: 2005-06-27

So if switching tabs makes it work, why can't I simulate this in the Applet with:
jTabbedPanel.setSelectedIndex(1);
jTabbedPanel.setSelectedIndex(0);
?

I tried this and it had no effect yet switching tabs with the mouse works OK.

> This is a known issue, we still don't good way to fix it.

Is there a bad way to fix it? Users aren't going to think of switching tabs to fix it.

Regards,

Simon.

michael_shan
Offline
Joined: 2005-05-29

Hi,
It's some complicated. After all other components are ready, add below to the end:

jTabbedPanel.setSelectedIndex(1);//other page
Thread.sleep(2000);//sleep some time
jTabbedPanel.setSelectedIndex(0); //web browser page

really a bad way :( .

michael_shan
Offline
Joined: 2005-05-29

Hi,

Another workaround, try JTabbedPane ->WebBrowser instead of JTabbedPane ->JPanel/JScrollPane ->WebBrowser.

michael_shan
Offline
Joined: 2005-05-29

Hi,
This's a common problem of Canvas. For JTabbedPane->JPanel->Canvas, the canvas's paint() method will not be called untill tab is switched. Here is a sample to reproduce:

//a customized canvas
package jfc;
import java.awt.Canvas;
import java.awt.Graphics;
public class MyCanvas extends Canvas {
public void paint(Graphics g) {
System.out.println("print canvas");
}
}
//show it ...
JPanel p1 = new JPanel();
Canvas canvas = new MyCanvas();
p1.add(canvas);
JTabbedPane tab = new JTabbedPane();
tab.add("1", p1);
frame.getContentPane().add(tab);
....

The "print canvas" will never show when the app starts.(If given two tabs and switch between them, the canvas will initialize normally).

michael_shan
Offline
Joined: 2005-05-29

Hi,
Bug http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4150034 seems related with this issue. I've tried mustang(please use newer than build 84,JDIC mozilla brower will not run under lowser versions for a bug of awt.)with your code, the "tab" issue works well :).

philabuster
Offline
Joined: 2006-07-06

Hi,
Thanks for your continued updates and support.

There are several webbrowser issues, some may not be tied to the canvas/tab/init problem. Does mustang fix all the problems or just the webbrowser tab startup problem?

I would prefer that a solution be found in the current version since it may be risky to tie my product release to a future release date of mustang (along with a new batch of bugs).

On the other hand, if mustang is JDIC nirvana then I may be forced to consider it as an alternative.

michael_shan
Offline
Joined: 2005-05-29

Hi,

Some confuse here. The "tab" issue is caused by a bug of Canvas,as you know JDIC is a Canvas component. JDIC web browser isn't available in Mustang now,I suggested you change jre to mustang.

I'll go on looking into the internal frame's z-order issue, but that's also a "common" problem(not JDIC,but Canvas)and will give you updates.

michael_shan
Offline
Joined: 2005-05-29

Hi,
You issue looks like http://forums.java.net/jive/thread.jspa?forumID=72&threadID=7130&message... .Issue132(https://jdic.dev.java.net/issues/show_bug.cgi?id=132) has been opened for that,but the bug should have been fixed.

For the issue of JInternalFrame, refer http://java.sun.com/products/jfc/tsc/articles/mixing/ . We don't suggest you use it.

To solve your problem, you'd better post your sample code and let's reproduce it and fix it.

Thanks,
Michael

philabuster
Offline
Joined: 2006-07-06

OK, I stripped down the code to make a small unit test for the JDIC webbrowser in the environment that I am using it - an MDI JApplet including a couple of JInternalFrames under NetBeans 5.0.

I have included "Unit Tests" and "Workarounds" in a menu bar. The applet starts up with the Workarounds disabled - so you can see the raw behavior with none of my workarounds. But first you must click on the "Another View" tab and then click on the WebBrowser tab to allow the webbrowser to initialize.

You can enable the workarounds to see what improvements I've been able to achieve - these may give some clues too. For example, I've noticed that resizing the Webbrowser JInternal may cause it to redraw the webbrowser, so that you can see its content again.

I haven't been totally successful with the workarounds as you will see and I don't like the flashs seen during webbrowser restoration etc. I would like a real solution where I don't need workarounds.

Without any workarounds, very little works properly with the webbrowser and the Applet will likely end up in a hung state. You will notice a number of broken things including but not limited to:

1. You can make the webbrowser initialize by clicking on "Another View" tab then back on the "WebBrowser Tab".

2. If the webbrowser isn't initialized, the applet hangs when you try to close it.

3. Minimizing/Iconifying and restoring the webbrowser JInternalFrame causes the applet to hang.

4. Resizing the webbrowser JInternalFrame by dragging a corner larger and then smaller will leave the webbrowser pane hanging in the larger size - not obeying its container.

5. If you drag the left JInternalFrame across the webbrowser pane, it is covered due to the Z-order problem.

6. Doing a "Unit Tests"/"Test Navigate", followed by a click refocus on the left JInternaFrame and then a click refocus back onto the webbrowser JInternalFrame will leave the webbrowser pane blank; however, slightly resize the webbrowser JInternalFrame by dragging on its boundary and it will reappear.

... too many little things to mention here - look for yourself.

I saw several issues that were similar but I don't believe the problem is as simple as stated.

Thanks for your help. The code for the unit test follows:

========================
/*
* JDIC_WEbbrowser_applet.java
*
* Created on May 30, 2006, 12:41 PM
*/

package org.fenetrix.jdic_applet;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Point;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import javax.swing.DesktopManager;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTree;
import javax.swing.MenuElement;
import javax.swing.table.DefaultTableModel;
import javax.swing.text.PlainDocument;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import org.jdesktop.jdic.browser.*;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import java.net.URL;
import java.net.MalformedURLException;
import java.awt.Dimension;
/**
*
*/

public class JAppletBrowser extends javax.swing.JApplet {

/** Initializes the applet */
public void init() {
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
public void run()
{
init_webbrowser();
initComponents();
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}

private void init_webbrowser()
{
webBrowser = new WebBrowser();

webBrowser.addWebBrowserListener(
new WebBrowserListener()
{
public void initializationCompleted(WebBrowserEvent event)
{
System.out.println("webBrowser initializationCompleted event");

//WORKAROUND: when jInternalFrame min/max causes another init of WebBrowser
if(workarounds_enabled && is_webbrowser_initialized)
{
//WORKAROUND: when re-init, restore previous content.
if((webbrowser_html_content != null) && (webbrowser_html_content.length() > 0))
webBrowser.setContent(webbrowser_html_content);
else if(webbrowser_url != null)
{
webBrowser.setURL(webbrowser_url);
}
else
loadStartingPage();

//WORKAROUND: to make initial viewport visible ...
// *** idea: maximize/restore jInternalFrame
is_webbrowser_reinit = true;
DesktopManager dm = jDesktopPane_webbrowser_ut.getDesktopManager();
dm.maximizeFrame(jInternalFrame_webbrowser);
dm.minimizeFrame(jInternalFrame_webbrowser);
}
else
{
loadStartingPage();
jMenu_UnitTests.setEnabled(true);
is_webbrowser_initialized = true;
}
}
public void downloadStarted(WebBrowserEvent event) {;}
public void downloadCompleted(WebBrowserEvent event) {;}
public void downloadProgress(WebBrowserEvent event) {;}
public void downloadError(WebBrowserEvent event) {;}
public void documentCompleted(WebBrowserEvent event)
{
System.out.println("webBrowser documentCompleted event");

// WORKAROUND: on webbrowser re-focus re-init, reload state / dom html
if(workarounds_enabled && is_webbrowser_reinit)
{
// need to re-init webbrowser after re-init
is_webbrowser_reinit = false; // show done with webbrowser state restore
}
else
{
// process_new_document();
}
}

public void titleChange(WebBrowserEvent event)
{
System.out.println("webBrowser titleChange event");
}

public void statusTextChange(WebBrowserEvent event)
{
//System.out.println("statusTextChange");
}
}
);

// added to track webbrowser focus, and hierarchy

webBrowser.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusGained(java.awt.event.FocusEvent evt) {
webBrowserFocusGained(evt);
}
});

webBrowser.addHierarchyListener(new java.awt.event.HierarchyListener() {
public void hierarchyChanged(java.awt.event.HierarchyEvent evt) {
webBrowserHierarchyChanged(evt);
}
});

//////////////
webBrowser.setDebug(true);
}

private void loadStartingPage()
{
System.out.println("loadStartingPage()");
String blank_page = "";

webBrowser_setContent(blank_page);
}

private void test_webbrowser_setcontent()
{
System.out.println("test_webbrowser_setcontent");
webbrowser_html_content = "


Unit Test: setContent succeeded.

";
webBrowser_setContent(webbrowser_html_content);
}

private void test_webbrowser_navigate()
{
System.out.println("test_webbrowser_navigate");
try
{
webBrowser_setURL(new URL("http://www.sun.com"));
}
catch (MalformedURLException ex)
{
ex.printStackTrace();
System.err.println("Exception:" + ex);
}
}

private void webBrowser_setContent(String newContent)
{
if(workarounds_enabled)
{
webbrowser_url = null;
webbrowser_html_content = newContent;
}
webBrowser.setContent(newContent);
}

private void webBrowser_setURL(URL newURL)
{
if(workarounds_enabled)
{
webbrowser_html_content = "";
webbrowser_url = newURL;
}
webBrowser.setURL(newURL);
}

/** This method is called from within the init() method to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
//
private void initComponents() {
jPopupMenu_domtree = new javax.swing.JPopupMenu();
jMenuItem_props = new javax.swing.JMenuItem();
jDesktopPane_webbrowser_ut = new javax.swing.JDesktopPane();
jInternalFrame_webbrowser = new javax.swing.JInternalFrame();
jTabbedPane_otherviews = new javax.swing.JTabbedPane();
jScrollPane_webbrowser = new JScrollPane(webBrowser.asComponent());
jScrollPane_another = new javax.swing.JScrollPane();
jTextPane_another = new javax.swing.JTextPane();
jScrollPane_webbrowser_tree = new javax.swing.JScrollPane();
jTree_webbrowser_tree = new javax.swing.JTree();
jInternalFrame_left = new javax.swing.JInternalFrame();
jScrollPane_left = new javax.swing.JScrollPane();
jTree_left = new javax.swing.JTree();
jMenuBar_webbrowser_ut = new javax.swing.JMenuBar();
jMenu_UnitTests = new javax.swing.JMenu();
jMenuItem_Test_SetContent = new javax.swing.JMenuItem();
jMenuItem_Test_Navigate = new javax.swing.JMenuItem();
jMenu_workarounds = new javax.swing.JMenu();
jCheckBoxMenuItem_workarounds = new javax.swing.JCheckBoxMenuItem();

jMenuItem_props.setText("Properties");
jMenuItem_props.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem_propsActionPerformed(evt);
}
});

jPopupMenu_domtree.add(jMenuItem_props);

jInternalFrame_webbrowser.setClosable(true);
jInternalFrame_webbrowser.setIconifiable(true);
jInternalFrame_webbrowser.setMaximizable(true);
jInternalFrame_webbrowser.setResizable(true);
jInternalFrame_webbrowser.setTitle("jInternalFrame_webbrowser");
jInternalFrame_webbrowser.setVisible(true);
jInternalFrame_webbrowser.addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
jInternalFrame_webbrowserInternalFrameActivated(evt);
}
public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
}
public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
jInternalFrame_webbrowserInternalFrameDeiconified(evt);
}
public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
jInternalFrame_webbrowserInternalFrameIconified(evt);
}
public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
}
});

jTabbedPane_otherviews.addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentShown(java.awt.event.ComponentEvent evt) {
jTabbedPane_otherviewsComponentShown(evt);
}
});
jTabbedPane_otherviews.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusGained(java.awt.event.FocusEvent evt) {
jTabbedPane_otherviewsFocusGained(evt);
}
});
jTabbedPane_otherviews.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
jTabbedPane_otherviewsStateChanged(evt);
}
});

jScrollPane_webbrowser.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
jScrollPane_webbrowser.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
jScrollPane_webbrowser.addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentHidden(java.awt.event.ComponentEvent evt) {
jScrollPane_webbrowserComponentHidden(evt);
}
public void componentResized(java.awt.event.ComponentEvent evt) {
jScrollPane_webbrowserComponentResized(evt);
}
public void componentShown(java.awt.event.ComponentEvent evt) {
jScrollPane_webbrowserComponentShown(evt);
}
});
jScrollPane_webbrowser.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusGained(java.awt.event.FocusEvent evt) {
jScrollPane_webbrowserFocusGained(evt);
}
public void focusLost(java.awt.event.FocusEvent evt) {
jScrollPane_webbrowserFocusLost(evt);
}
});
jScrollPane_webbrowser.addHierarchyListener(new java.awt.event.HierarchyListener() {
public void hierarchyChanged(java.awt.event.HierarchyEvent evt) {
jScrollPane_webbrowserHierarchyChanged(evt);
}
});

jTabbedPane_otherviews.addTab("WebBrowser", jScrollPane_webbrowser);

jScrollPane_another.addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentShown(java.awt.event.ComponentEvent evt) {
jScrollPane_anotherComponentShown(evt);
}
});
jScrollPane_another.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusGained(java.awt.event.FocusEvent evt) {
jScrollPane_anotherFocusGained(evt);
}
});

jTextPane_another.setEditable(false);
jScrollPane_another.setViewportView(jTextPane_another);

jTabbedPane_otherviews.addTab("Another View", jScrollPane_another);

jScrollPane_webbrowser_tree.setViewportView(jTree_webbrowser_tree);

org.jdesktop.layout.GroupLayout jInternalFrame_webbrowserLayout = new org.jdesktop.layout.GroupLayout(jInternalFrame_webbrowser.getContentPane());
jInternalFrame_webbrowser.getContentPane().setLayout(jInternalFrame_webbrowserLayout);
jInternalFrame_webbrowserLayout.setHorizontalGroup(
jInternalFrame_webbrowserLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jInternalFrame_webbrowserLayout.createSequentialGroup()
.add(jScrollPane_webbrowser_tree, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 186, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jTabbedPane_otherviews, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 498, Short.MAX_VALUE)
.addContainerGap())
);
jInternalFrame_webbrowserLayout.setVerticalGroup(
jInternalFrame_webbrowserLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jInternalFrame_webbrowserLayout.createSequentialGroup()
.add(11, 11, 11)
.add(jTabbedPane_otherviews, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 504, Short.MAX_VALUE))
.add(jScrollPane_webbrowser_tree, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 515, Short.MAX_VALUE)
);
jInternalFrame_webbrowser.setBounds(200, 10, 710, 550);
jDesktopPane_webbrowser_ut.add(jInternalFrame_webbrowser, javax.swing.JLayeredPane.DEFAULT_LAYER);

jInternalFrame_left.setMaximizable(true);
jInternalFrame_left.setResizable(true);
jInternalFrame_left.setTitle("jInternalFrame_left");
jInternalFrame_left.setVisible(true);
jScrollPane_left.setViewportView(jTree_left);

org.jdesktop.layout.GroupLayout jInternalFrame_leftLayout = new org.jdesktop.layout.GroupLayout(jInternalFrame_left.getContentPane());
jInternalFrame_left.getContentPane().setLayout(jInternalFrame_leftLayout);
jInternalFrame_leftLayout.setHorizontalGroup(
jInternalFrame_leftLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jScrollPane_left, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
);
jInternalFrame_leftLayout.setVerticalGroup(
jInternalFrame_leftLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jScrollPane_left, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 515, Short.MAX_VALUE)
);
jInternalFrame_left.setBounds(10, 10, 190, 550);
jDesktopPane_webbrowser_ut.add(jInternalFrame_left, javax.swing.JLayeredPane.DEFAULT_LAYER);

jMenu_UnitTests.setText("Unit Tests");
jMenu_UnitTests.setEnabled(false);
jMenuItem_Test_SetContent.setText("Test Webbrowser SetContent");
jMenuItem_Test_SetContent.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
jMenuItem_Test_SetContentMouseReleased(evt);
}
});

jMenu_UnitTests.add(jMenuItem_Test_SetContent);

jMenuItem_Test_Navigate.setText("Test Navigate");
jMenuItem_Test_Navigate.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
jMenuItem_Test_NavigateMouseReleased(evt);
}
});

jMenu_UnitTests.add(jMenuItem_Test_Navigate);

jMenuBar_webbrowser_ut.add(jMenu_UnitTests);

jMenu_workarounds.setText("Workarounds");
jCheckBoxMenuItem_workarounds.setText("Use Workarounds");
jCheckBoxMenuItem_workarounds.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
jCheckBoxMenuItem_workaroundsItemStateChanged(evt);
}
});

jMenu_workarounds.add(jCheckBoxMenuItem_workarounds);

jMenuBar_webbrowser_ut.add(jMenu_workarounds);

setJMenuBar(jMenuBar_webbrowser_ut);

org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jDesktopPane_webbrowser_ut, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 821, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(31, 31, 31)
.add(jDesktopPane_webbrowser_ut, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 625, Short.MAX_VALUE)
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
}//

private void jCheckBoxMenuItem_workaroundsItemStateChanged(java.awt.event.ItemEvent evt) {
System.out.println("jCheckBoxMenuItem_workaroundsItemStateChanged" );
JCheckBoxMenuItem cb = (JCheckBoxMenuItem) evt.getItemSelectable();
workarounds_enabled = cb.getState();
System.out.println("workarounds_enabled set to:" + workarounds_enabled);
}

private void jMenuItem_Test_NavigateMouseReleased(java.awt.event.MouseEvent evt) {
test_webbrowser_navigate();
}

private void jMenuItem_propsActionPerformed(java.awt.event.ActionEvent evt) {
System.out.println("jMenuItem_propsActionPerformed");
}

private void jScrollPane_webbrowserHierarchyChanged(java.awt.event.HierarchyEvent evt) {
System.out.println("jScrollPane_pageviewHierarchyChanged");
}

private void jScrollPane_anotherComponentShown(java.awt.event.ComponentEvent evt) {
}

private void jScrollPane_anotherFocusGained(java.awt.event.FocusEvent evt) {
System.out.println("jScrollPane4FocusGained");
}

private void jTabbedPane_otherviewsFocusGained(java.awt.event.FocusEvent evt) {
System.out.println("jTabbedPane_otherviewsFocusGained");
}

private void jInternalFrame_webbrowserInternalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
System.out.println("jInternalFrame_webviewInternalFrameIconified");
}

private void jInternalFrame_webbrowserInternalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
System.out.println("jInternalFrame_webviewInternalFrameDeiconified");
}

private void jInternalFrame_webbrowserInternalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
System.out.println("jInternalFrame_webviewInternalFrameActivated");
}

private void jScrollPane_webbrowserFocusLost(java.awt.event.FocusEvent evt) {
System.out.println("jScrollPane_pageviewFocusLost");
}

private void jScrollPane_webbrowserComponentHidden(java.awt.event.ComponentEvent evt) {
System.out.println("jScrollPane_pageviewComponentHidden");
}

private void jScrollPane_webbrowserComponentShown(java.awt.event.ComponentEvent evt) {
System.out.println("jScrollPane_pageviewComponentShown");

///// Determine the nature of the requestFocusInWindow() failure.
// if(webBrowser.requestFocusInWindow())
// System.out.println("webBrowser.requestFocusInWindow succeeded");
// else
// {
// System.out.println("webBrowser.requestFocusInWindow failed.");
// System.out.println(" webBrowser.isFocusable() =" + webBrowser.isFocusable() + ", .isDisplayable() =" + webBrowser.isDisplayable() + ", .isVisible() =" + webBrowser.isVisible() + ", .isShowing() =" + webBrowser.isShowing());
// System.out.println(" jScrollPane_another.isDisplayable() =" + jScrollPane_another.isDisplayable());
// System.out.println(" jTabbedPane_otherviews.isDisplayable() =" + jTabbedPane_otherviews.isDisplayable());
// System.out.println(" jInternalFrame_webbrowser.isDisplayable() =" + jInternalFrame_webbrowser.isDisplayable());
// }
//////
}

private void jScrollPane_webbrowserFocusGained(java.awt.event.FocusEvent evt) {
System.out.println("jScrollPane_webbrowserFocusGained");
if(workarounds_enabled)
{
DesktopManager dm = jDesktopPane_webbrowser_ut.getDesktopManager();
dm.maximizeFrame(jInternalFrame_webbrowser);
dm.minimizeFrame(jInternalFrame_webbrowser);
}
}

private void jTabbedPane_otherviewsComponentShown(java.awt.event.ComponentEvent evt) {
System.out.println("jTabbedPane_otherviewsComponentShown, selectedIndex=" + jTabbedPane_otherviews.getSelectedIndex());
}

private void jScrollPane_webbrowserComponentResized(java.awt.event.ComponentEvent evt) {
System.out.println("jScrollPane_webbrowserComponentResized, applying workaround...");
if(workarounds_enabled && is_webbrowser_initialized)
{
webBrowser.setSize(jScrollPane_another.getSize()); //WORKAROUND: fix minimize/maximize problem
}
}

private void jTabbedPane_otherviewsStateChanged(javax.swing.event.ChangeEvent evt) {
System.out.println("jTabbedPane_otherviewsStateChanged, selectedIndex=" + jTabbedPane_otherviews.getSelectedIndex());
}

private void webBrowserHierarchyChanged(java.awt.event.HierarchyEvent evt) {
System.out.println("webBrowserHierarchyChanged:");
System.out.println(" getChangeFlags()=" + evt.getChangeFlags());
System.out.println(" paramString()=" + evt.paramString());
}
private void webBrowserFocusGained(java.awt.event.FocusEvent evt) {
System.out.println("webBrowserFocusGained");
}

private void jMenuItem_Test_SetContentMouseReleased(java.awt.event.MouseEvent evt) {
test_webbrowser_setcontent();
}

///////////////////////////////////////////////////////////////////////////////
//private final WebBrowser webBrowser = new WebBrowser(); // no difference
private WebBrowser webBrowser = null;
private boolean workarounds_enabled = false;

//WORKAROUND: webbrowser re-focus/re-init, keep track of init state
private boolean is_webbrowser_initialized = false;
private boolean is_webbrowser_reinit = false;
private URL webbrowser_url = null;

//WORKAROUND: webbrowser re-focus/re-init, save content globally to restore
private String webbrowser_html_content = "";
///////////////////////////////////////////////////////////////////////////////

// Variables declaration - do not modify
private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem_workarounds;
private javax.swing.JDesktopPane jDesktopPane_webbrowser_ut;
private javax.swing.JInternalFrame jInternalFrame_left;
private javax.swing.JInternalFrame jInternalFrame_webbrowser;
private javax.swing.JMenuBar jMenuBar_webbrowser_ut;
private javax.swing.JMenuItem jMenuItem_Test_Navigate;
private javax.swing.JMenuItem jMenuItem_Test_SetContent;
private javax.swing.JMenuItem jMenuItem_props;
private javax.swing.JMenu jMenu_UnitTests;
private javax.swing.JMenu jMenu_workarounds;
private javax.swing.JPopupMenu jPopupMenu_domtree;
private javax.swing.JScrollPane jScrollPane_another;
private javax.swing.JScrollPane jScrollPane_left;
private javax.swing.JScrollPane jScrollPane_webbrowser;
private javax.swing.JScrollPane jScrollPane_webbrowser_tree;
private javax.swing.JTabbedPane jTabbedPane_otherviews;
private javax.swing.JTextPane jTextPane_another;
private javax.swing.JTree jTree_left;
private javax.swing.JTree jTree_webbrowser_tree;
// End of variables declaration

}

========================

simonmcmahon
Offline
Joined: 2005-06-27

I have many of the same problems in the sample code that I posted in "JDIC does not shutdown correctly when rendering .DOC files".

My code causes the init failure when a tabbed panel is used but I dont get the shutdown failure unless I am browsing a local .DOC file.

I also had the resizing problem but it can be solved by using setPreferredSize(0,0) on the WebBrowser panel.