Skip to content
Snippets Groups Projects
View.java 1.33 KiB
Newer Older
  • Learn to ignore specific revisions
  • Kovax's avatar
    v2
    Kovax committed
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    
    package GUI.game;
    
    
    Kovax's avatar
    Kovax committed
    import GUI.Window.Window;
    
    Kovax's avatar
    v2
    Kovax committed
    import java.awt.GridLayout;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    
    /**
     *
     * @author Kovax
     */
    
    Kovax's avatar
    Kovax committed
    public class View extends Window
    {   
        private Controller controller;
        private Model model;
    
    Kovax's avatar
    v2
    Kovax committed
        private JFrame frame;
        
    
        public View(Controller game, Model gameModel)
    
    Kovax's avatar
    v2
    Kovax committed
        {
    
            this.model      = gameModel;
            this.controller = game;
            
    
    Kovax's avatar
    v2
    Kovax committed
            this.setSize(400,400);
    
            this.setLayout(new GridLayout(controller.settings.size,controller.settings.size));
    
    Kovax's avatar
    Kovax committed
    
    
    Kovax's avatar
    Kovax committed
        }
    
    Kovax's avatar
    v2
    Kovax committed
        public void draw()
        {
    
            model.build();
            for(int i=0;i<controller.settings.size;i++)
            {
                for(JButton actButton : model.squares[i])
                {
                    this.add(actButton);
                }
            }
    
    Kovax's avatar
    v2
    Kovax committed
            if( this.frame != null )
            {
                  frame.dispose();
            }
            
            this.frame = new JFrame("Aknakereső");
            frame.add(this);
            frame.setSize(400,400);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);
        }
    
    Kovax's avatar
    v2
    Kovax committed
    }