From fcb028014a8c4a1e33484149a2ea93a9880dd6ec Mon Sep 17 00:00:00 2001 From: WickedJack99 Date: Wed, 1 Nov 2023 20:52:38 +0100 Subject: [PATCH] Created main frame. --- src/main/java/gui/src/frames/MainFrame.java | 103 ++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 src/main/java/gui/src/frames/MainFrame.java diff --git a/src/main/java/gui/src/frames/MainFrame.java b/src/main/java/gui/src/frames/MainFrame.java new file mode 100644 index 0000000..b6e7ef2 --- /dev/null +++ b/src/main/java/gui/src/frames/MainFrame.java @@ -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); + } + } +} +