Layout Problem

"Jerre duine" <[email protected]>
Newsgroups gmane.comp.embedded.carlsbad-cubes
Message-ID <[email protected]>
Hello,

I have a layout problem...

Description of the situation:
1) In XML format: a frame in border layout.
2) In XML format: the frame contains 5 panels.
3) In XML format: 3 of the 5 panels contain labels.
4) Class (DynamicPanel) extending JPanels with only one constructor which 
add 3 buttons to the panel and set a flowlayout. This panel is added to the 
CENTER and the EAST panel.

Problem:
1) When you make the window smaller, the CENTER buttons (from DynamicPanel) 
slide under the EAST and the WEST panel while I expected that they would 
come one under each other.
2) The EAST panel stays longer seems to have priority over the CENTER panel, 
it disapears later. But also the EAST panel doesn't show the expected 
flowlayout.

Problem Code:

1) Java file with main()

   import org.swixml.SwingEngine;
   import javax.swing.*;

   public class Gui {

     private SwingEngine swix;
     public JPanel centerPnl;
     public JPanel eastPnl;

     private Gui() throws Exception {
   	swix=new SwingEngine( this );
	swix.render( "TestTemplate.xml" ).setVisible( true );
   	centerPnl.add(new DynamicPanel());
	eastPnl.add(new DynamicPanel());
	JFrame f = (JFrame) swix.getRootComponent();
	f.pack();
     }
     public static void main( String[] args ) throws Exception {
	new Gui();
     }
   }

2) Dynamic panel class extending from JPanel

   import java.awt.FlowLayout;
   import javax.swing.JButton;
   import javax.swing.JPanel;

   public class DynamicPanel extends JPanel {
        public DynamicPanel() {
	super();
	setLayout(new FlowLayout());
	for (int i = 0; i < 3; i++) {
	       this.add(new JButton("test"+i));
	}
         }
   }

3) The XML file

<?xml version="1.0" encoding="iso-8859-1"?>
<frame size="800,300" title="Layout Test" 
DefaultCloseOperation="JFrame.EXIT_ON_CLOSE">
<panel Layout="borderlayout">
	<panel id="northPnl" background="red"  constraints="BorderLayout.NORTH">
		<label Foreground="blue" text="south"/>
	</panel>
	<panel id="westPnl" background="yellow"  constraints="BorderLayout.WEST">
		<label Foreground="blue" text="west"/>
	</panel>
	<panel id="centerPnl" background="grey"  
constraints="BorderLayout.CENTER"/>
	<panel id="eastPnl" background="yellow" constraints="BorderLayout.EAST"/>
	<panel id="southPnl" background="red" constraints="BorderLayout.SOUTH">
		<label Foreground="south" text="InfoPanel"/>
	</panel>
</panel>
</frame>

Thanks for your response,
Jerre

_________________________________________________________________
Online gamen ? http://www.msn.be/games/online/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.