The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Canvas in JFrame, does not show content

Hello guys,

on a previous post I have asked for help and, later on, succeeded in developing a browser using SWT.
Now, since I wanted to embed it, I have put it into a Canvas and now I need to add this canvas onto a JFrame.

The problem is that the canvas is added (you can see the area it allocates), but the content of the canvas (the webpage), does not show up.
But, if I create a whole new JFrame just for the canvas, then it works.
But I need to have just 1 Frame with the browser in it.

I am running a thread for the GUI and then a thread for the Browser.

I will add, from a different class, the component Canvas and set its bounds. here is some code:

Re: Canvas in JFrame, does not show content

I actually realized that the canvas is shown only few times (have no idea why). It looks like a 50% chance.
Is there a way to force the draw of a canvas or JPanel? (I put the canvas into a Jpanel)
I thought there was something like repaint or redraw or simply refresh but nothing.

Re: Canvas in JFrame, does not show content

Just second the SSCCE advice. I would be interested to test this, but cannot given the small code snippet. It may have to do with mixing heavy and light components, but presume it has more to do with mixing Swing and SWT (I presume this is SWT?).

It is called AFTER all the other methods (DB and GUI).
I basically put the Canvas into a JPanel and add the JPanel to the main frame.

I am using swing for the GUI.

And I am not using any layout manager, I am just setting statically their position on the frame (do you suggest me to use one?)
I have tried this only on MacOSX, and I have found out that around 50% of the times the JPanel is not loaded.

Extra: Whenever it is successfully shown, I have noticed that when I move around the map (from google.maps), the only way to refresh what is contained on the JPanel is to Resize the form, I have tried to repack the form, to revalidate the component etc... but nothing...