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

ymazal_ca used Ask the Experts™
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();
		Container contentPane = tempy.getContentPane();
		contentPane.setLayout(new FlowLayout());
		   JInternalFrame FrameSIP = new JInternalFrame();
	        contentPane.add(FrameSIP, FlowLayout.CENTER);
	        //tempy.setLayout(new FlowLayout());
	        //FrameSIP.setSize(300, 300); 

Open in new window

Watch Question

Do more with

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

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

then add the frame without position:

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

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