Why I should use a JPanel?

后端 未结 6 1718
你的背包
你的背包 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:45

    The purpose is to group components together.

    Look at this web page for example. You could imagine a center panel with the question and answers laid out vertically, a right panel containing yet other panels: one for the blog, one for the job announcement, one for the related questions, and finally a south panel for the footer.

    The footer panel can be reused in other pages than question pages.

    The layout of the page as a whole is easier to understand and implement if you divide it into independant panels.

提交回复
热议问题