klasscho

GuiPanel

May 31st, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.28 KB | None | 0 0
  1. package com.packadge.gui;
  2.  
  3. import java.awt.*;
  4. import java.awt.event.MouseEvent;
  5. import java.util.ArrayList;
  6.  
  7. public class GuiPanel {
  8.  
  9.     private ArrayList<GuiButton> buttons;
  10.  
  11.     public GuiPanel(){
  12.         buttons = new ArrayList<GuiButton>();
  13.     }
  14.  
  15.     public void update(){
  16.         for (GuiButton b : buttons){
  17.             b.update();
  18.         }
  19.     }
  20.  
  21.     public void render(Graphics2D g){
  22.         for (GuiButton b : buttons){
  23.             b.render(g);
  24.         }
  25.     }
  26.  
  27.     public void add(GuiButton button){
  28.         for (GuiButton b : buttons){
  29.             buttons.add(button);
  30.         }
  31.     }
  32.  
  33.     public void remove(GuiButton button){
  34.         for (GuiButton b : buttons){
  35.             buttons.remove(button);
  36.         }
  37.     }
  38.  
  39.     public void mousePressed(MouseEvent e){
  40.         for (GuiButton b : buttons){
  41.             b.mousePressed(e);
  42.         }
  43.     }
  44.  
  45.     public void mouseReleased(MouseEvent e){
  46.         for (GuiButton b : buttons){
  47.             b.mouseReleased(e);
  48.         }
  49.     }
  50.  
  51.     public void mouseDragged(MouseEvent e){
  52.         for (GuiButton b : buttons){
  53.             b.mouseDragged(e);
  54.         }
  55.     }
  56.  
  57.     public void mouseMoved(MouseEvent e){
  58.         for (GuiButton b : buttons){
  59.             b.mouseMoved(e);
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment