0
public class IncomeStatementPanel extends JPanel
{
private JLabel costOfGoodSoldIncState = new JLabel("Cost of goods sold", SwingConstants.RIGHT);
private JLabel ebitIncState = new JLabel("EBIT", SwingConstants.RIGHT);
private JLabel deprecIncState = new JLabel("Depreciation", SwingConstants.RIGHT);
...
//I want to add more panels to this, but don't know the code to create them.
public IncomeStatementPanel()
{
//Set grid layout for the panel
setLayout(new GridLayout(14,2,0,0));
}
}
那么'add'方法呢? – 2011-03-16 21:48:40
不扩展'JPanel'可能会使代码更容易。同时删除标签的字段(在正常情况下,您应该能够在面板上拍打它们并忘记它们)。 – 2011-03-16 21:52:30