JPanel 是一种中间层容器,它能容纳组件并将组件组合在一起,但它本身必须添加到其他容器中使用。JPanel 类的构造方法如下:
1.JPanel():使用默认的布局管理器创建新面板,默认的布局管理器为 FlowLayout。
2.JPanel(LayoutManagerLayout layout):创建指定布局管理器的 JPanel 对象。
创建一个JPanel对象
JPanel jp = new JPanel();//创建一个JPanel对象
jp.setBackground(Color.#xxxxxx);//设置背景
jp.add