Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.gui;
- import java.awt.*;
- import java.awt.event.MouseEvent;
- import java.util.HashMap;
- public class GuiScreen {
- private static GuiScreen screen;
- private HashMap<String, GuiPanel> panels = new HashMap<>();
- private String currentPanel = "";
- private GuiScreen(){}
- public static GuiScreen getInstance(){
- if (screen == null){
- screen = new GuiScreen();
- }
- return screen;
- }
- public void update(){
- if (this.panels.get(this.currentPanel) != null){
- ((GuiPanel)this.panels.get(this.currentPanel)).update();
- }
- }
- public void render(Graphics2D g){
- if (this.panels.get(this.currentPanel) != null){
- ((GuiPanel)this.panels.get(this.currentPanel)).render(g);
- }
- }
- public void add(String panelName, GuiPanel panel){
- this.panels.put(panelName, panel);
- }
- public void setCurrentPanel(String panelName){
- this.currentPanel = panelName;
- }
- public void mousePressed(MouseEvent e){
- if (this.panels.get(this.currentPanel) != null){
- ((GuiPanel)this.panels.get(this.currentPanel)).mousePressed(e);
- }
- }
- public void mouseReleased(MouseEvent e){
- if (this.panels.get(this.currentPanel) != null) {
- ((GuiPanel)this.panels.get(this.currentPanel)).mouseReleased(e);
- }
- }
- public void mouseDragged(MouseEvent e){
- if (this.panels.get(this.currentPanel) != null) {
- ((GuiPanel)this.panels.get(this.currentPanel)).mouseDragged(e);
- }
- }
- public void mouseMoved(MouseEvent e){
- if (this.panels.get(this.currentPanel) != null) {
- ((GuiPanel)this.panels.get(this.currentPanel)).mouseMoved(e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment