1

Here is my current settings:

    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)

lowerContent's all component are displayed as expected while upperContent didn't display the component that i was added to it by using the following code:

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

i also used label.repaint(); & upperContent.revalidate() neither worked

mKorbel
  • 109,525
  • 20
  • 134
  • 319
skystar7
  • 4,419
  • 11
  • 38
  • 41
  • 1
    Use layouts (+layout padding and borders) to achieve the required effect. The `null` layout will come back to bite you in the posterior. – Andrew Thompson Feb 10 '12 at 00:46

1 Answers1

2

You get absolute positioning with a null layout. The bad news is that everything is totally up to you from then on.

http://docs.oracle.com/javase/tutorial/uiswing/layout/none.html

duffymo
  • 305,152
  • 44
  • 369
  • 561