Newer
Older
/*
* 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;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class View extends Window
{
private Controller controller;
private Model model;
public void timeLeft()
{
this.timeLeft++;
this.timeLeftLabel.setText(Integer.toString(this.timeLeft));
}
public View(Controller game, Model gameModel)
this.model = gameModel;
this.controller = game;
this.setSize(controller.settings.size*46,controller.settings.size*26);
//w41 h26
this.setLayout(new GridLayout(controller.settings.size,controller.settings.size));
model.build();
for(int i=0;i<controller.settings.size;i++)
{
for(JButton actButton : model.squares[i])
{
this.add(actButton);
}
}
//Kulso panel
JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
frame.setSize(controller.settings.size*46,(controller.settings.size+4)*26);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
GridBagConstraints c = new GridBagConstraints();
JPanel upper = new JPanel();
upper.setSize(controller.settings.size*41,100);
JLabel points = new JLabel();
JButton stopButton = new JButton();
points.setText("points");
stopButton.setText("buton");
c.fill = GridBagConstraints.EAST;
c.gridx = 0;
c.gridy = 0;
upper.add(stopButton);
upper.add(points);
panel.add(upper,c);
JPanel buttons = new JPanel();
buttons.add(this);
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridy = 1;