• Post Reply Bookmark Topic Watch Topic
  • New Topic

About Canvas and Swing  RSS feed

 
Shay Gaghe
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Vinod Venugopal
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can override the paintComponent() method & draw on the JPanel directly.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!