The method setBorder(Border)
is provided by JComponent
. A JPanel
extends JComponent
so it inherits the method.
That code is using the AWT based Panel
which does not extend JComponent
. Use a JPanel
(and use Swing components consistently) instead.