If I want to display ellipses and rectangles on a screen, should I use a canvas or a JPanel?
What is the difference? When do I use each?
Canvas is an AWT object; JPanel is a lightweight Java Swing object. If you have a Java Swing GUI, I'd strongly recommend using JPanel.
Here's a good link on JPanel:
In the simplest case, you use a
JPanelexactly the same way as you would aPanel. Allocate it, drop components in it, then add theJPanelto someContainer. However,JPanelalso acts as a replacement forCanvas(there is noJCanvas)...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With