Why do we need to extend JFrame in a swing application?

前端 未结 4 1044
悲&欢浪女
悲&欢浪女 2020-12-01 22:11

Why do we need to extend the JFrame class when building a Swing application. As far as I know extends is used for inheriting the base class. None o

4条回答
  •  温柔的废话
    2020-12-01 22:33

    To use JFrame in your application You can extend it as you did it in your code or make an object as

    JFrame frame= new JFrame();
    

    and then you can do it

    frame.setTitle("Title");
    frame.setLayout(layout);
    

    do it in either way as you are easy but to use JFrame in Application and to access its methods etc you have to use one of these methods

提交回复
热议问题