contentPane.add(FrameSIP, FlowLayout.CENTER); crushes

ymazal_ca
ymazal_ca used Ask the Experts™
on
Hi experts,
The included code shows an error because the contentPane.add(FrameSIP, FlowLayout.CENTER); is not accepted.

Any one knows why ?
public static void main(String[] args) {
		mainWindow tempy = new mainWindow();
		
		tempy.setVisible(true);
		
		Container contentPane = tempy.getContentPane();
		contentPane.setLayout(new FlowLayout());
 
		
		   JInternalFrame FrameSIP = new JInternalFrame();
		   
	        FrameSIP.setVisible(true);
	        
	        //FrameSIP.set
	        contentPane.add(FrameSIP, FlowLayout.CENTER);
	        //tempy.setLayout(new FlowLayout());
	        //FrameSIP.setSize(300, 300); 
 
 
	}

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
To get the Center Flow Layout, construct the layout with center position:
    contentPane.setLayout(new FlowLayout(FlowLayout.CENTER));


then add the frame without position:
    contentPane.add(FrameSIP);
>>tempy.setVisible(true);

that should be after all the statement you want to execute before the frame gets displayed.

>>contentPane.setLayout(new FlowLayout());

why do you set flowlayout? by default frame is constructed with BorderLayout which is sufficient!

check this example for setting up JInternalFrame http://www.java2s.com/Code/Java/Swing-JFC/InternalFramedemo.htm

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial