Vita_Harvey

Cell_B

Mar 2nd, 2019
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 KB | None | 0 0
  1. package csc143.sudoku;
  2.  
  3. import javax.swing.*;
  4. import java.awt.*;
  5.  
  6. /**
  7.  * @author Vita Wiebe
  8.  * @version PA2
  9.  * A helper class to make a cell inside a SudokuBoard object.
  10.  */
  11. class Cell extends JPanel {
  12.  
  13.     int row;
  14.     int column;
  15.          
  16.      /** Our class constructor.
  17.       * Determines size and shape of Cell object, which has
  18.       * been standardized for the purposes of this assignment.
  19.       * @param int row, used to keep board position.
  20.       * @param int column, used to keep board position.
  21.       */
  22.      public Cell(int row, int column) {        
  23.          this.row = row;
  24.          this.column = column;
  25.          setPreferredSize(new Dimension(50, 50));    
  26.          add(new JLabel(row + ", " + column));
  27.          setOpaque(false);
  28.          setEnabled(true);        
  29.      }
  30.      
  31.     /**
  32.      * This method renders one 50x50 "cell" to add to cell array "cells".
  33.      * @param g The Graphics object use to render
  34.      */
  35.     @Override
  36.     public void paintComponent(java.awt.Graphics g) {
  37.        
  38.         // paint the underlying component
  39.         super.paintComponent(g);
  40.                              
  41.         // set the color of the outline        
  42.         g.setColor(Color.BLACK);
  43.                
  44.         g.drawRect(0, 0, 47, 47);
  45.                        
  46.     }
  47. }
Add Comment
Please, Sign In to add comment