I am creating a tab pain in a Class called Dashboard which holds 'filler' panels in the tabs. I am wondering if there is a way to create a new Dashboard and change the panels that I stored in the tabs. I'm not sure if this is the right way to explain it, but here is some code.
public class Dashboard{
public Dashboard(){
tabPane = new JTabbedPane();
panel1 = new JPanel();
panel2 = new JPanel();
panel3 = new JPanel();
panel1.add(new JLabel("This is the first panel"));
panel2.add(new JLabel("This is the second panel"));
panel3.add(new JLable("This is the third panel"));
tabPane.add("One", panel1);
tabPane.add("Two", panel2);
tabPane.add("Three", panel3);
}
I now want to make a new class that creates and instance of the Dashboard, but changes what panels show up in the tabs. I was trying something like this:
public class Changer{
public Changer(){
Dashboard d = new Dashboard();
// assuming I have getters and setters in the above class and that the
// panels are fields in Dashboard
JPanel new = new JPanel();
d.setPanel1(new);
}
}
I'm not sure if this is possible or if there is another way of doing so.