MagicView - t for(int x = 0; x<this.size; x++) {...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.awt.*; import java.util.*; import javax.swing.*; public class MagicView extends JFrame implements MagicObservers{ private int size; private MagicButton board[][]; Container c; private MagicModel model; private MagicController controller; public MagicView() { this.model = new MagicModel(); this.model.addObservers(this); this.controller = new MagicController(this.model); this.size = model.SIZE; this.setSize(500, 500); this.setTitle("Magic square"); c = this.getContentPane(); c.setLayout(new GridLayout(this.size, this.size)); this.board = new MagicButton[this.size][this.size];
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: t for(int x = 0; x<this.size; x++) { for(int y = 0; y<this.size; y++) { MagicButton button = new MagicButton(x, y); button.addActionListener(this.controller); this.board[x][y] = button; this.board[x][y].setText(" "); this.c.add(button); } } this.setVisible(true); } public static void main(String arg) { MagicView m = new MagicView(); } @Override public void updateCurrent(MagicButtonEvent mbe) { this.board[mbe.getX()][mbe.getY()].setText("" + mbe.getValue()); t } }...
View Full Document

Ask a homework question - tutors are online