Differences between components and lightweight/heavyweight

后端 未结 4 1377
野的像风
野的像风 2020-12-16 18:24

What is the difference between JPanel and JFrame and relationship to lightweight, heavyweight?

4条回答
  •  春和景丽
    2020-12-16 19:18

    A JFrame is a Swing container with an interface box, and can be a standalone application (it has the top box with abilities to minimize, maximize, and exit) whereas a JPanel is everything a JFrame is (a Swing container) minus the ability to be a standalone. For a JPanel to work, it must be inside something like a frame, like a JFrame.

    The other answer has a good definition of lightweight and heavyweight components.

    use: I use JPanels within JFrames to easily run multithreaded programs that integrate together (I have a JPanel runnable class inside my class that extends JFrame, I run that as its own thread and the JPanel class can change the value of variables in the JFrame class). I use it to easily get different threads to interact with each other. **You can have multiple JPanels within a JFrame.

提交回复
热议问题