I am writing an application in Java and I am running into issues with a JTabbedPane filled with a JLayeredPane that contains 2 JPanels. I need to have two different pages (profile and edit profile) so that the Profile Tab shows the profile and the button "edit profile" from the Profile JPanel will bring up another JPanel with Edit Profile. First off is this an acceptable idea?
I have the Profile JPanel and editProfile JPanel both using the SpringLayout Manager. I have read that the JLayeredPane won't work with LayoutManagers but by using it on JPanels it should work, right? I have some sample code that I've written below that i feel should work, but all i get is a blank tab. Any help would be great. Thanks.
public class rework extends UserInterface {
private static SpringLayout infoLocation = new SpringLayout();
private static SpringLayout editLocation = new SpringLayout();
private static JPanel infoPane = new JPanel(infoLocation);
private static JPanel editPane = new JPanel(editLocation);
private static JLayeredPane manager = new JLayeredPane();
public static JLayeredPane displayScreen() {
JLabel lblProfile = new JLabel("Profile");
JLabel lblEditProfile = new JLabel("Edit Profile");
infoPane.add(lblProfile, SpringLayout.WEST);
editPane.add(lblEditProfile, SpringLayout.WEST);
infoLocation.putConstraint(SpringLayout.WEST, lblProfile, 5, SpringLayout.WEST, infoPane);
infoLocation.putConstraint(SpringLayout.NORTH, lblProfile, 5, SpringLayout.NORTH, infoPane);
editLocation.putConstraint(SpringLayout.WEST, lblEditProfile, 5, SpringLayout.WEST, editPane);
editLocation.putConstraint(SpringLayout.NORTH, lblEditProfile, 5, SpringLayout.NORTH, editPane);
manager.add(editPane, JLayeredPane.DEFAULT_LAYER);
manager.add(infoPane, JLayeredPane.PALETTE_LAYER);
return manager;
}
}