2012-02-10 14 views
1

は、ここに私の現在の設定です:絶対配置でコンポーネントをJComponentに追加する方法は?

upperContentは、私は次のコードを使用して、それに追加されたコンポーネントは表示されませんでしたが、予想通りlowerContentのすべてのコンポーネントが表示され
private JComponent upperContent = new GeneralContent(); 
    private JComponent lowerContent = new GeneralContent(); 
    // GeneralContent extends JComponent 

    jframe.setLayout(new GridLayout(2, 0)); 
    upperContent.setLayout(null); 
    lowerContent.setLayout(new GridBagLayout()); 
    jframe.add(upperContent); 
    jframe.add(lowerContent) 

JLabel label=new JLabel(); 
upperContent.add(label); 
label.setLocation(15,15); 

をIまた、label.repaint(); & upperContent.revalidate()どちらも機能していません

+1

使用レイアウト(+レイアウトのパディングとボーダー)必要な効果を実現しています。 'ヌル'レイアウトはあなたを後部に噛ませるために戻ってくるでしょう。 –

答えて

関連する問題