added footer to outside tab panel to switch between them
This commit is contained in:
1 parent
41740249ca
commit
624cdaf1f4
1 file changed
+43
-2
@@ -31,7 +31,7 @@ public class MainViewer {
|
|||||||
viewer.setVisible(true);
|
viewer.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void populateMainPanel(JFrame viewer) {
|
private void populateMainPanel(JFrame viewer) {
|
||||||
JTabbedPane outer = new JTabbedPane();
|
JTabbedPane outer = new JTabbedPane();
|
||||||
JTabbedPane userT = new JTabbedPane();
|
JTabbedPane userT = new JTabbedPane();
|
||||||
JTabbedPane contactT = new JTabbedPane();
|
JTabbedPane contactT = new JTabbedPane();
|
||||||
@@ -66,7 +66,15 @@ public class MainViewer {
|
|||||||
contactT.addTab("Address", address);
|
contactT.addTab("Address", address);
|
||||||
outer.addTab("Contact", contactT);
|
outer.addTab("Contact", contactT);
|
||||||
|
|
||||||
viewer.getContentPane().add(outer);
|
// Create main container with BorderLayout
|
||||||
|
JPanel mainContainer = new JPanel(new BorderLayout());
|
||||||
|
mainContainer.add(outer, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
// Add footer with navigation buttons
|
||||||
|
JPanel footer = createFooter(outer);
|
||||||
|
mainContainer.add(footer, BorderLayout.SOUTH);
|
||||||
|
|
||||||
|
viewer.getContentPane().add(mainContainer);
|
||||||
viewer.revalidate();
|
viewer.revalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,4 +258,37 @@ public class MainViewer {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private JPanel createFooter(JTabbedPane tabbedPane) {
|
||||||
|
JPanel footer = new JPanel(new BorderLayout());
|
||||||
|
footer.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||||
|
|
||||||
|
JButton prevButton = new JButton("Previous Section");
|
||||||
|
JButton nextButton = new JButton("Next Section");
|
||||||
|
|
||||||
|
// Style the buttons
|
||||||
|
prevButton.setFocusPainted(false);
|
||||||
|
nextButton.setFocusPainted(false);
|
||||||
|
|
||||||
|
// Add action listeners
|
||||||
|
prevButton.addActionListener(e -> {
|
||||||
|
int currentIndex = tabbedPane.getSelectedIndex();
|
||||||
|
if (currentIndex > 0) {
|
||||||
|
tabbedPane.setSelectedIndex(currentIndex - 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
nextButton.addActionListener(e -> {
|
||||||
|
int currentIndex = tabbedPane.getSelectedIndex();
|
||||||
|
if (currentIndex < tabbedPane.getTabCount() - 1) {
|
||||||
|
tabbedPane.setSelectedIndex(currentIndex + 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add buttons to footer
|
||||||
|
footer.add(prevButton, BorderLayout.WEST);
|
||||||
|
footer.add(nextButton, BorderLayout.EAST);
|
||||||
|
|
||||||
|
return footer;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user