Java swing: custom all - subclass of jcomponent or jpanel or ...?

Hiya - fast - is there any harm / value in the JComponent subclass compared to JPanel?

They look the same to me if I make my own drawing and the object will not have any children, however, it seems to have a prefix for subclassing JPanel over JComponent - just looking for opinions on why this might be ...

thanks: -)

+3
source share
1 answer

If you draw the entire component yourself, use JComponent. JPanel is just a simple concrete instance of JComponent (which is abstract) and is not really intended to override its methods.

JPanel , / , .

+7

Source: https://habr.com/ru/post/1703185/


All Articles