I trying to use jmenuitem to call other class.
When you click the jmenuitem you get the other class gui.
But mine actionlistener part working. It removes all but doesnt fill/get the from other class.
Here is the codes.
First one is the main:
The second one is the other class. i want to use.;
I can make them work with only 1 class. when there are 2 class i get problem.
I am doing it to learn more aboout Java.
I appreciate if anyone could help.
Joined: Nov 01, 2006
First of all:
You don't need line 27, as pane already is your contentPane and app is added to that in line 21. Since pane is your contentPane you don't need to change that as you do in line 52.
Try to see here:
As you can see, I remove app from the contentPane, add et.getGui() to it and force a repaint of the contentPane.
Now to your problem:
The size of the panel taken from Anotherclass hasn't been set. True, you just add the app to the conentPane of the JFrame and app is shown in the correct size, but that is because of line 60. Your app is Anotherclass hasn't been shown so it doesn't have an adjusted size, it is 0 by 0 pixels. In the example above I also call pane.toLayout() to force a re-layout of the components added to the pane, in this case the et.getGui()-panel. This results in the et.getGui()-panel being resized according to it's parent container's size.