-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMasterFrame.java
More file actions
39 lines (33 loc) · 1.33 KB
/
MasterFrame.java
File metadata and controls
39 lines (33 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import javax.swing.*;
import java.awt.*;
public class MasterFrame {
public static JFrame masterFrame;
public static JPanel[] appPanels = {new StartingPanel(), new AppPanel(), new HomePanel(), new PersonalDataPanel(), new ShoppingPanel(), new AppPanel()};
public static String[] appPanelsString = {"StartingPanel","ProductDataPanel","HomePanel","PersonalDataPanel","ShoppingPanel","PaymentPanel"};
public MasterFrame(JFrame masterFrame){
this.masterFrame = masterFrame;
masterFrame.setLayout(new FlowLayout());
changePanel("StartingPanel");
}
public static void changePanel(String panelName){
int index = indexOf(panelName, appPanelsString);
for(int i=0;i<appPanels.length;i++){
if(i==index){
System.out.println(appPanelsString[i]+" "+String.valueOf(true));
masterFrame.add(appPanels[i]);
}
else{
System.out.println(appPanelsString[i]+" "+String.valueOf(false));
masterFrame.remove(appPanels[i]);
}
}
}
public static int indexOf(String element, String[] array){
for(int i=0;i<array.length;i++){
if(array[i].equals(element)){
return i;
}
}
return 0;
}
}