This test is designed to emulate the execution of code that adds a background image to jpanl in NetBeans
The data type of the car class is defined in Jpdemo, but the anonymous inner class is used when assigning the object, inherits the car class, is its subclass, and overrides the parent class's Run method, because the parent class's constructor automatically executes the Run method, the output sun run, proves that the rewrite succeeds, Then execute Super.run again, calling the parent class not overriding the Run method, so the output fater run.
The code to add a background graph to jpanl is similar to this:
New Javax.swing.JPanel () { protectedvoid paintcomponent (java.awt.Graphics g) { Super. paintcomponent (g); G.drawimage (new Javax.swing.ImageIcon (GetClass () getresource ("/reg/images/login.png")). GetImage (), 0,0,1070,85,null);} ;
Create an anonymous inner class to inherit jpanl, then rewrite the Paintcomponent method, then call the parent class Paintcomponent method and send back the G parameter representing a background graph, you can load the picture when printing
Add background image to jpanl in NetBeans understanding of code--Anonymous inner class inherits parent class