Hi guys, I´m making an interface for some math exercises. I have a window per exercise (3 now) and now I want to work with all of them in one single window, by clicking a button in the main window, and replacing the content of it with the content of the window of the exercises choose.
But with my actual skills, what I get is a new window over the main. I think I should change the constructor of the exercises classes, but I don´t know how.
¿How can I fix this?
The code for each exercise window (all whit the same structure) is this:
And the code for the three JButton of the main window is:
Thanks for the point Rob. In the CardLayout tutorial, I found the JTabbedPane, that I think its more suitable for my scenario.
But now I get a similar problem, for each exercise I put in the tabbedpane, I got a blank window under the main window.
In the image, I have put one exercise (tab 1, I don´t modified the title), and that is the blank window under I get:
¿Is the problem then in the classes constructor I put above?
Joined: Jun 13, 2009
Thats the way layout managers work. By default a JFrame uses a BorderLayout. When you add the tabbed pane to the center of the BorderLayout, the tabbed pane will now occupy all the space available in the frame. If this is not what you want the use (for example):
to see the difference.
Joined: Jul 19, 2009
Sorry Rob, I think I expressed myself wrong ( I´m from Spain)
The point its that the program generates a blank window under the main program for each exercise class of mine that I add to the main program, like I pointed in the image:
That means, I have 3 blank windows when I execute my complete main program with my three exercises together.
¿What you say is that is the normal thing? because if it is, I prefer to do 3 separated jars.
Joined: Jul 19, 2009
I finally found the solution
Then, it´s just simple like comment the .setVisible(true) in the frames of the classes that you are going to put in one single window in a main program.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com