Why I should use a JPanel?

后端 未结 6 1719
你的背包
你的背包 2021-01-13 15:32

What\'s the difference between:

public class Test {

    public static void main(String[] args) {
        JButton button= new JButton(\"1\");
        button.         


        
6条回答
  •  北荒
    北荒 (楼主)
    2021-01-13 15:35

    There is basically no visual difference in your two examples, but the UI is too poor for exhibiting a difference. A JPanel is exactly what a panel is in real life, something used to display things inside it. It is generally used to contains different elements that you want to display in a given layout.

提交回复
热议问题