Is this code bad practice as the method show()
is deprecated? Is it okay to override here?
public class Window extends JFrame {
public Window() {
// Do things.
}
public void show() { // <- Comes up with a warning as deprecated code.
// Do other things.
}
}
When it's a class that you're extending, it's ideally better to avoid overriding a deprecated method, as in a future release when/if that is removed, and you need to upgrade to the newer version of the library, you will have to rework with the removed method which was deprecated.
If in your instance this is the JFrame class that you're extending, and you intend to override the show()
method, you can instead override the setVisible(boolean b)
method (doc) which is the replacement for the show()
method as mentioned in the javadoc.
Also, it is not advisable to override a base class method and entirely change its function, as
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