Skip to content
Snippets Groups Projects
View.java 1.5 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;
    import javax.swing.JPanel;
    
    /**
     *
     * @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 JButton[][] squares;
        private JFrame frame;
        
        public View()
        {
            this.setSize(400,400);
            this.setLayout(new GridLayout(6,6));
            squares = new JButton[6][6];
        
        }
    
    Kovax's avatar
    Kovax committed
    
        View(Controller game, Model gameModel) 
        {
            this.model = gameModel;
            this.controller = game;
        }
    
    Kovax's avatar
    v2
    Kovax committed
        public void draw()
        {
            this.build();
            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);
        }
        public void build()
        {
            for(int i=0;i<6;i++)
            {
                 for(int j=0;j<6;j++)
                 {
                      squares[i][j] = new JButton();
                      squares[i][j].setSize(400,400);
                      this.add(squares[i][j]);
                     
                 }
            }
        }
    }