Skip to main content

Question - Using Webclient awt component in Swing app

5 replies [Last post]
dhecksel
Offline
Joined: 2003-06-11
Points: 0

First, per the Swing J1 BOF, I am posting a question. A
brief intro on my background - 11 years in IBM Software
( mostly Networking Software ), 4 years CTO at a
Web personalization startup ( I was on the 1998
Swing "Early Vendor experience" JavaOne panel ). I
started with Swing 0.30. I have been with Sun
Microsystems 3+ years now - in the Java Center,
Sun Software Services.

I have a need/desire to integrate the Webclient Html
rendering AWT component from mozilla.org into a Swing
application. From the bof, it sounded like some folks
had some "known workarounds" for doing that. Yes, there
are likely some heavyweight/lightweight issues. Are there
any known helpful workarounds known today for
integrating the Webclient awt component into a Swing
application?

Thanks for the help...

Dave

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
bino_george
Offline
Joined: 2003-06-16
Points: 0

Sorry it took so long for us to answer. I was trying to get a recent build of webclient for Linux setup so that I can play with it to see what kind of issues you may run into.

The main thing about WebClient is that the BrowserControlCanvas which is the class where the rendering happens (as far as I can tell) is really just a subclass of AWT canvas. So all the issues that apply to embedding a HW component in a LW component apply to this scenario.

Please refer to the HW/LW mixing document written by Amy Fowler :
http://java.sun.com/products/jfc/tsc/articles/mixing/

This article highlights the problem areas. As long as you
avoid these problem areas, you should be OK.

One of the frequently asked features in AWT is to solve the LW/HW mixing issue. We thought about using the Shape
extension to do shape clipping such that LW/HW mixing is
no longer a problem. Unfortunately this feature did not
make it into Tiger due primarily to resource limitations.
But this may be possible in a future release. But for the
moment as long as you stick to the guidelines in the above
document, it is possible to get this working well.

I hope this was of some help, if you try this and run into
more issues, please post on this board and we will try to help you out.

Regards,
Bino.

augusto
Offline
Joined: 2003-06-11
Points: 0

This is a good article for converting from 1.0 style event mechanism, to 1.1. If your original code uses 1.0 style AWT code this is the first step.

http://java.sun.com/docs/books/tutorial/post1.0/converting/convertingAWT...
[b]How to Convert Code that Uses the AWT[/b]

As for moving to Swing, well, that depends on your app. It might be a lot of work for a big UI, but not too much trouble for a small client. You will have to go through the pain of replacing All heavy weight components with their Swing counter parts. This is not too dificult in most cases, but can be a bit tedious. Let me know what specifics you need to know, I had to do this with our app and it's all working great.

augusto
Offline
Joined: 2003-06-11
Points: 0

I though you were porting an old app into swing. if i read correctly (again) you're trying to use an AWT component inside of a JFrame?

Yes, there are workarounds, this article will help you;

http://java.sun.com/products/jfc/tsc/articles/mixing/

Make sure you call JPopupMenu.setDefaultLightWeightPopupEnabled(false)

dhecksel
Offline
Joined: 2003-06-11
Points: 0

Augusto,

Many thanks - I will check out the "mixing"
article. And yes - my question was not about
converting event style - but using the "AWT" based
"webclient" browser component ( Mozilla.org ) with
a Swing application - it is the mixing workarounds
that I'm interested.

And - I am hoping the Swing team is tracking a
requirement to get better integration of "webclient"
with Swing.

jeff
Offline
Joined: 2003-06-10
Points: 0

Hi Dave,

Great seeing you at JavaOne! We're tracking this down for you - hope to post something soon.

:)

jeff