File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT / JFace and the fly likes About Canvas and Swing Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply Bookmark "About Canvas and Swing" Watch "About Canvas and Swing" New topic
Author

About Canvas and Swing

Shay Gaghe
Ranch Hand

Joined: Sep 03, 2001
Posts: 102
Hi Guys!
im using Swing interface. i know that i shouldnt use AWT and Swing components together although its possible.
i extending the Canvas class and i draw an Image inside ,in mt interface i add the Canvas to a Jpanel. my question are ; sould i be worry about using the Canvas and thw Swing component in the same interface?
what benefits i get by using Canvas and can you suggust about good(Swing) alternative?
thanks
Gregg Bolinger
Sheriff

Joined: Jul 11, 2001
Posts: 15040

The only real problem I ran into was when I had a Canvas and then a JMenu. The JMenu would appear behind the Canvas.
So I switched to just using a JLabel instead of Canvas. Everything works.
You might try setting the Canvas to the MIN_VALUE and see if that puts it behind everything correctly if you have a similar problem. I never did try it.

------------------
Happy Coding,
Gregg Bolinger


My Blog | DZone Articles
Vinod Venugopal
Ranch Hand

Joined: Dec 06, 2000
Posts: 148
You can override the paintComponent() method & draw on the JPanel directly.


- Vinod<br />-------<br />SCJP2
 
 
subject: About Canvas and Swing
 
Threads others viewed
drawRect()
showInputDialog( ) focus
Difference between Panel and Canvas
problem in showing canvas on pocket pc...
Making a ScrollPane resize along with its parent Frame
MyEclipse, The Clear Choice