更新时间:2023-12-05 18:03:34
JPanel#paint
, it is recommended that use JPanel#paintComponent
, check out Performing Custom PaintinggetPreferredSize
method of Class2
and return an appropriate size of the layout manager....
JPanel p4 = new JPanel(); // Default layout manager is FlowLayout
Class2 c2o = new Class2();
// c2o has not size (0x0 by default)...
p4.add(c2o);
p4.setBounds(0,115,500,55);
f.add(p4);