I have following two classes: JDialog and JFrame (see signature below). I want them to have few extra methods, but I also want them both to extend my code, without rewriting the code Is it possible to do that?
java.awt.Window » java.awt.Dialog » javax.swing.JDialog
java.awt.Window » java.awt.Frame » javax.swing.JFrame
Suppose I am trying to add the function moveWindowToMagicPositionOnScreen(), to move the window to the user-friendly position on users screen.I want the function to apply to both the JDialog and JFrame classes. Using the inheritance, I am trying to write two classes, for example MagicJDialog and MagicJFrame, each of them will implement the method moveWindowToMagicPositionOnScreen() in the identical way. So I will not want to write the code twice. I want only one class to utilize the code of the other class.