The interface I am working on is described in this question Load a new JPanel into an existing JPanel. I would have added to that post, but it would have made it too long. I hope I am not violating the rules by starting another question to ask for more help.
I was told that what I wanted to do can be done with a card layout, so I attempted to create a class to build one. Here it is:
package com.troymarkerenterprises;
import javax.swing.*;
import java.awt.*;
import java.util.Objects;
public class ClassBottomFrame extends JPanel {
JPanel cards;
final static String TITLECARD = "Title Card";
final static String DEPARTMENTLIST = "Department List";
final static String GRADELIST = "Grade List";
final static String USERLIST = "User List";
private Image image;
public void addComponentToPane(Container pane) {
JPanel card1 = new JPanel();
card1.setBackground(Color.BLACK);
JLabel jl = new JLabel();
jl.setIcon(new javax.swing.ImageIcon(Objects.requireNonNull(getClass().getResource("/i_phoenix.png"))));
jl.setVisible(true);
card1.add(jl);
JPanel card2 = new JPanel();
card2.add(new JLabel("Department List"));
JPanel card3 = new JPanel();
card3.add(new JLabel("Grade List"));
JPanel card4 = new JPanel();
card4.add(new JLabel("User List"));
cards = new JPanel(new CardLayout());
cards.add(card1, TITLECARD);
cards.add(card2, DEPARTMENTLIST);
cards.add(card3, GRADELIST);
cards.add(card4, USERLIST);
pane.add(cards, BorderLayout.CENTER);
}
private void createAndShowGUI() {
JPanel panel = new JPanel();
this.setBackground(Color.BLACK);
this.addComponentToPane(panel);
this.setVisible(true);
}
public ClassBottomFrame() {
this.createAndShowGUI();
this.showCard(TITLECARD);
}
public void showCard(String card) {
CardLayout cl = (CardLayout) (cards.getLayout());
cl.show(cards, card);
}
}
At the moment, this does nothing, just displays a blank area on the screen. This class will be responsible for drawing the bottom half of the display screen shown in the previously mentioned question. At the moment each card will only display to the title of the card, and nothing else. I am just trying to get it working, then I will add more. If it would be more helpful to see all my code, it is posted here: https://github.com/troy-marker/TMEA-0002-J.