Well, most people do their drawing for Swing apps on a JPanel, but I was wondering if there is any difference between using a Canvas and JPanel to do the drawing in terms of advantages/disadvantages, if any.
I have heard that Canvas is supposed to be for AWT, not Swing, is that right?
Canvas v. JPanel
Page 1 of 14 Replies - 4807 Views - Last Post: 11 August 2010 - 08:23 PM
Replies To: Canvas v. JPanel
#2
Re: Canvas v. JPanel
Posted 11 August 2010 - 04:44 PM
Canvas is awt and jpanel is swing. However, Swing is built on top of awt so you can use awt in swing applications.
If you need a buffer strategy you meed to use a canvas. However, my feelings are you should be using JPanel unless this is necessary.
If you need a buffer strategy you meed to use a canvas. However, my feelings are you should be using JPanel unless this is necessary.
#3
Re: Canvas v. JPanel
Posted 11 August 2010 - 07:36 PM
Canvas is the most efficient component for painting, and it is double-buffered. There is a reason Sun never made a JCanvas. Unless you are doing heavy-duty painting, you should be fine with a normal JPanel.
#4
Re: Canvas v. JPanel
Posted 11 August 2010 - 07:52 PM
Alrighty, I'll keep those facts in mind, thanks!
#5
Re: Canvas v. JPanel
Posted 11 August 2010 - 08:23 PM
If you are doing your own painting and not using Layout
If you are not using any JComponent (button, label, textfield, comboBox,...)
use Canvas
else use JPanel
If you are not using any JComponent (button, label, textfield, comboBox,...)
use Canvas
else use JPanel
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote







|