0

I have a main panel that looks like this:

JPnael mainPanel = new JPanel();
mainPanel .setLayout(new BorderLayout());

And I include sub panels, like this:

mainPanel.add(new JPanel(), BorderLayout.NORTH));
mainPanel.add(new JPanel(), BorderLayout.CENTER));

I want to create another JPanel, but not in BorderLayout, it needs to be absolute position. How can I do this?

Update: I tried this variant, but it not suitable for BorderLayout

JPanel absPanel = new JPanel();
JLabel absLbl = new JLabel("aaaaaaaaa");
absPanel.setLayout(null);
absPanel.add(absLbl);
absPanel.setBounds(0, 0, 100, 100);
mainPanel.add(absPanel, ???);
Raziel
  • 444
  • 6
  • 22
phpnuker
  • 43
  • 3
  • 8
  • 1
    *"I want to create another JPanel, but not in BorderLayout, its need be absolute position"* No it doesn't. Provide ASCII art of how the GUI is suppose to look at normal size, and when expanded. – Andrew Thompson May 27 '13 at 07:32
  • 1
    I would avoid null/absolute layouts with a passion, instead, if I found that I need to position the componets with more accuracy then is provided by the available, I'd look to developing my own. Take a look at [this](http://stackoverflow.com/questions/14635952/java-layout-proportions-creating-a-scalable-square-panel/14636828#14636828) and [this](http://stackoverflow.com/questions/11819669/absolute-positioning-graphic-jpanel-inside-jframe-blocked-by-blank-sections/11822601#11822601) for example – MadProgrammer May 27 '13 at 08:28

1 Answers1

0

It's not really clear what is the visual effect you're trying to achieve, but you may try using the layered pane

gcvt
  • 1,482
  • 13
  • 15