What are the pros and cons of extending a JFrame rather than create a new JFrame?
For example:
public class Test extends JFrame {
setVisible(true);
}
or
public class Test {
JFrame test = new JFrame():
test.setVisible(true);
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You should not extend a class, unless you want to actually extend its functionality, in the example you’ve shown, you should use option 2, as option 1 is an abuse of the
extending feature.In other words – as long as the answer to the question is Test a
JFrame? is NO, it should not extendJFrame.