I have two panels that i wish to display to the user. I decided to add them to a JTabbedPane. I also want to allow the user to have a side by side view of them both at the same time. So I added the two panels to my JTabbedPane and then i created a JSplitPanel as such :
tabs.addTab("Align Image Points", imageControlPanel);
tabs.addTab("Align Map Points", mapControlPanel);
JSplitPane splitPane = new JSplitPane(
JSplitPane.HORIZONTAL_SPLIT, true, imageControlPanel,
mapControlPanel);
tabs.addTab("Side by side view", splitPane);
The resulting JTabbedPane only has one tab! When i remove the JSplitPane everything works ok. Two tabs. I then tried simplifying the problem to post here and i came up with this :
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
public class Test {
public static void main(String[] args) {
JFrame f = new JFrame("Test");
JButton b1 = new JButton("First");
JButton b2 = new JButton("Second");
JSplitPane s = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,b1,b2);
JTabbedPane tabs = new JTabbedPane();
tabs.addTab("First", b1);
tabs.addTab("Second", b2);
tabs.addTab("Both", s);
f.getContentPane().add(tabs);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.pack();
f.setVisible(true);
}
}
This gave me another problem! It displays 3 tabs but the third tab's split pane displays no buttons!
So my question is What is wrong with JSplitPanel? You can't have it display objects that are already displayed in another tab? It makes no sense. Please help me.
(Note: i don't want to duplicate the components that i am about to display as i want them to be the same reference)