Created main frame.

This commit is contained in:
WickedJack99
2023-11-01 20:52:38 +01:00
parent 75ad39c4b6
commit fcb028014a

View File

@@ -0,0 +1,103 @@
/**
* @author Aaron Moser
* @date 31.10.2023
*/
package gui.src.frames;
import javax.swing.JFrame;
import javax.swing.JPanel;
import gui.src.constants.GUIConstants.Panel;
import gui.src.constants.GUIConstants.Theme;
import gui.src.interfaces.Themeable;
import gui.src.menubar.MenuBar;
import gui.src.panels.ControllingPanel;
import gui.src.panels.MonitoringPanel;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
public class MainFrame extends JFrame implements Themeable {
private static MainFrame instance;
private MainFrame() {
this.setTitle("Firewall Dashboard");
this.setJMenuBar(MenuBar.getMenuBar());
this.setPanel(Panel.MonitoringPanel);
this.setSize(800, 400);
this.setLocation(300, 200);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static MainFrame getInstance() {
if (null == instance) {
instance = new MainFrame();
}
return instance;
}
private void setPanel(JPanel panel) {
this.setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.gridwidth = 1;
constraints.gridheight = 1;
constraints.gridx = 0;
constraints.gridy = 0;
constraints.anchor = GridBagConstraints.CENTER;
this.add(panel, constraints);
}
public void setPanel(Panel kindOfPanel) {
try {
switch (kindOfPanel) {
case MonitoringPanel: {
this.setPanel(MonitoringPanel.getInstance());
}break;
case ControllingPanel: {
this.setPanel(ControllingPanel.getInstance());
}break;
default: {
throw new Exception("Unknown kind of panel.");
}
}
} catch (Exception e) {
System.err.println(e.getMessage());
this.setPanel(Panel.MonitoringPanel);
}
}
public void setThemeColor(Theme themeColor) {
try {
switch (themeColor) {
case Dark: {
}break;
case Light: {
}break;
default: {
throw new Exception("Unknown kind of theme color.");
}
}
} catch (Exception e) {
System.err.println(e.getMessage());
this.setThemeColor(Theme.Light);
}
}
}