Difference between JPanel, JFrame, JComponent, and JApplet

后端 未结 3 1919
你的背包
你的背包 2021-01-30 01:52

I\'m making a physics simulator for fun and I was looking up graphics tutorials when I tried to figure out the difference between all these J\'s. Can somebody elaborate on them

3条回答
  •  旧巷少年郎
    2021-01-30 02:19

    JFrame and JApplet are top level containers. If you wish to create a desktop application, you will use JFrame and if you plan to host your application in browser you will use JApplet.

    JComponent is an abstract class for all Swing components and you can use it as the base class for your new component. JPanel is a simple usable component you can use for almost anything.

    Since this is for a fun project, the simplest way for you is to work with JPanel and then host it inside JFrame or JApplet. Netbeans has a visual designer for Swing with simple examples.

提交回复
热议问题