mixing between AWT and swing
Hi there,
Last time this forum was very helpful which I greatly appreciate. This time I have a similar question. So here is the story: I try not to mix swing and awt since the components do not overlap correctly in the frame. However, I use someone else code in my own code which contains class "Canvas". My code uses swing components only. Somehow I need to replace the Canvas class. I tried JPanel. It compiles but does not produce the graphics Naturally, I am reluctant to go into the details of other person code and I gonna do it if no other option is left. I wonder what would be the advice in this case how to approach the problem
Thanks
[663 byte] By [
student_a] at [2007-11-26 12:24:14]

# 1
You may mix swing and awt if you follow these guidelines:
1. Do not mix lightweight (Swing) and heavyweight (AWT) components within a container
where the lightweight component is expected to overlap the heavyweight one.
2. Do not place heavyweight (AWT) components inside a JScrollPane.
If you need to scroll areas containing heavyweight components, use AWT's ScrollPane instead.
3. Do not place heavyweight (AWT) components inside a JInternalFrame.
4. If you place Swing popup components in a window containing heavyweight components
and it's possible that the popup windows will intersect a heavyweight, then invoke
JPopupMenu.setDefaultLightWeightPopupEnabled(false)
before the popup components are instantiated.
Source: http://java.sun.com/products/jfc/tsc/articles/mixing/