0
내가 가진 코드는 그냥 평소처럼 추가 할 수 있습니다JPanel을 이미 확장 한 클래스에서 패널을 중첩시키는 방법은 무엇입니까?
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'메소드는 어떻게됩니까? –
'JPanel'을 확장하지 않으면 코드를 더 쉽게 만들 수 있습니다. 또한 레이블 필드를 제거합니다 (정상적인 상황에서는 패널에서 해당 필드를 두드리고 잊어 버릴 수 있어야합니다). –