Hello.

https://www.cs.indiana.edu/classes/c212/spr2014/final/stageTwo/

import javax.swing.*; 

class Game extends JFrame {
  Game() {
    World world = new World();
    this.add(world);
    this.addKeyListener( world ); 
    this.setVisible(true); 
    this.setSize(200, 400); 
    this.setDefaultCloseOperation(EXIT_ON_CLOSE); 
    world.start(); 
  }
  public static void main(String[] args) {
    Game game = new Game(); 
  }
}

import java.awt.*; 

class Square {
  World world; 
  Color color;
  Square(World world, Color color, int row, int col) {
    this.world = world; 
    this.color = color; 
    this.row = row; 
    this.column = col; 
  }
  int row, column; // distance to top left corner of World 
  void draw(Graphics g) {
    int width = world.squareWidth(), height = world.squareHeight(); 
    int x = this.column * width, y = this.row * height; 
    g.setColor(this.color); 
    g.fillRect(x, y, width, height); 
    g.setColor(Color.WHITE); 
    g.drawRect(x, y, width, height); 
    g.setColor(Color.BLACK); 
  }
  public String toString() { // testing and debugging 
    return "Square(" + row + ", " + column + ")";  
  }
  boolean conflictsWith(int rows, int cols) {
    return row < 0 || row >= rows || column < 0 || column >= cols;  
  }
}

import javax.swing.*; 
import java.awt.*;
import java.awt.event.*; 

class World extends JComponent implements KeyListener, ActionListener {
  int count;
  public void actionPerformed(ActionEvent e) {
    this.count += 1; 
    System.out.println("Ouch..." + this.count);  
  }
  public void keyPressed(KeyEvent e) { 
    int value = e.getKeyCode();
    System.out.println("Key pressed: " + (char) value); 
    switch (value) {
      // http://docs.oracle.com/javase/6/docs/api/java/awt/event/KeyEvent.html#VK_LEFT
      case KeyEvent.VK_LEFT : System.out.println("Left arrow pressed."); break;
      case KeyEvent.VK_RIGHT: System.out.println("Right arrow pressed."); break;
      case KeyEvent.VK_UP   : System.out.println("Up arrow pressed."); break;
      case KeyEvent.VK_DOWN : System.out.println("Down arrow pressed."); break;
      case KeyEvent.VK_SPACE: System.out.println("Space bar pressed."); break;
      default: System.out.println("Unknown key pressed."); break; 
    }
  }
  public void keyReleased(KeyEvent e) { }
  public void keyTyped(KeyEvent e) { }
  Square a, b, c, d; 
  Timer timer;
  World() {
    this.timer = new Timer(1000, this); 
    this.a = new Square(this, Color.RED, 2, 3); 
    this.b = new Square(this, Color.BLUE, 3, 4); 
    this.c = new Square(this, Color.GREEN, 2, 5);     
    this.d = new Square(this, Color.YELLOW, 1, 4); 
  }
  void start() {
    this.timer.start();  
  }
  public void paintComponent(Graphics g) {
    g.drawString("Welcome to Tetris!", 50, 150);
    a.draw(g);
    b.draw(g);
    c.draw(g);
    d.draw(g);
    
  }
  static final int ROWS = 22;
  static final int COLS = 10; 
  int squareWidth() { return (int) getSize().getWidth() / World.COLS; }
  int squareHeight() { return (int) getSize().getHeight() / World.ROWS; }
}

So I understand Squares now. 

import javax.swing.*; 

class Game extends JFrame {
  Game() {
    World world = new World();
    this.add(world);
    this.addKeyListener( world ); 
    this.setVisible(true); 
    this.setSize(200, 400); 
    this.setDefaultCloseOperation(EXIT_ON_CLOSE); 
    world.start(); 
  }
  public static void main(String[] args) {
    Game game = new Game(); 
  }
}

import java.awt.*; 

class Square {
  World world; 
  Color color;
  Square(World world, Color color, int row, int col) {
    this.world = world; 
    this.color = color; 
    this.row = row; 
    this.column = col; 
  }
  int row, column; // distance to top left corner of World 
  void draw(Graphics g) {
    int width = world.squareWidth(), height = world.squareHeight(); 
    int x = this.column * width, y = this.row * height; 
    g.setColor(this.color); 
    g.fillRect(x, y, width, height); 
    g.setColor(Color.WHITE); 
    g.drawRect(x, y, width, height); 
    g.setColor(Color.BLACK); 
  }
  public String toString() { // testing and debugging 
    return "Square(" + row + ", " + column + ")";  
  }
  boolean conflictsWith(int rows, int cols) {
    return row < 0 || row >= rows || column < 0 || column >= cols;  
  }
}

import java.awt.*; 
import java.util.*; 

abstract class Shape {

  boolean moveDown() { 
    Map<String, Square> future = this.createMap(row + 1, column); 
    if (true) { // world.validates(future)) {
      this.squares = future; // also a few things
      // System.out.println( "I am going down." ); 
      this.row += 1; 
      return true; 
    } else {
      return false;  
    }
  } 

  boolean moveLeft() { 
    Map<String, Square> future = this.createMap(row, column-1); 
    if (true) { // world.validates(future)) {
      this.squares = future; 
      this.column -= 1; 
      return true; 
    } else {
      return false;  
    }
  } 

  boolean moveRight() { 
    Map<String, Square> future = this.createMap(row, column+1); 
    if (true) { // world.validates(future)) {
      this.squares = future; 
      this.column += 1; 
      return true; 
    } else {
      return false;  
    }
  } 

    boolean moveUp() { 
    Map<String, Square> future = this.createMap(row-1, column); 
    if (true) { // world.validates(future)) {
      this.squares = future; 
      this.row -= 1; 
      return true; 
    } else {
      return false;  
    }
  } 

  void draw(Graphics g) {
    for (String key : squares.keySet()) {
      Square square = squares.get(key); 
      if (square != null) 
        square.draw(g); 
    } 
  }  
  
  Map<String, Square> squares; 
  
  Map<String, Square> createMap(int row, int column) {
    Map<String, Square> squares = new HashMap<String, Square>(); 
    int[][] matrix = this.rotations[this.rotation];
    for (int i = 0; i < matrix.length; i++) {
      for (int j = 0; j < matrix[i].length; j++) {
        Square square = matrix[i][j] == 1 ? new Square(world, color, row + i, column + j) : null; 
        squares.put(i + ", " + j, square); 
      }
    }
    return squares; 
  }
  
  World world; 
  int row, column;
    
  Color color;
  
  Shape(int row, int column, World world) {
    this.row = row; 
    this.column = column; 
    this.world = world;
    this.squares = new HashMap<String, Square>(); 
  }
  
  int rotation; 
  
  int[][][] rotations; 
  
  static Shape randomShape(World world) {
    int which = 1; // (int)(Math.random() * 7 + 1); 
    switch (which) {
      case 1 : return new SquareShape   (0, world.COLS/2, world);  
      //case 2 : return new LShape        (0, world.COLS/2, world);
      //case 3 : return new SShape        (0, world.COLS/2, world); 
      //case 4 : return new ZShape        (0, world.COLS/2, world);
      //case 5 : return new MirroredLShape(0, world.COLS/2, world);
      //case 6 : return new LineShape     (0, world.COLS/2, world);
      default: return new TShape        (0, world.COLS/2, world);
    }
  }
  public String toString() {
    return this.squares + " at (" + row + ", " + column + ")"; 
  }
}

import java.awt.*; 

class SquareShape extends Shape {
  SquareShape(int row, int column, World world) {
    super(row, column, world); 
    this.color = new Color(204, 102, 204);  
    this.rotations = new int[][][] {
      { { 1, 1}, 
        { 1, 1} }, 
      { { 1, 1}, 
        { 1, 1} }, 
      { { 1, 1}, 
        { 1, 1} }, 
      { { 1, 1}, 
        { 1, 1} }
    };
    this.squares = createMap(row, column); 
  }
  public String toString() {
    return "SquareShape: " + super.toString(); 
  }
}

import java.awt.*; 

class TShape extends Shape {
  TShape(int row, int column, World world) {
    super(row, column, world); 
    this.color = new Color(204, 204, 102);
    this.rotations = new int[][][] {
      { { 1, 1, 1}, 
        { 0, 1, 0}, 
        { 0, 0, 0}}, //-------------------
      { { 0, 0, 1}, 
        { 0, 1, 1}, 
        { 0, 0, 1}}, //-------------------
      { { 0, 0, 0}, 
        { 0, 1, 0}, 
        { 1, 1, 1}}, //-------------------
      { { 1, 0, 0}, 
        { 1, 1, 0}, 
        { 1, 0, 0}}  //------------------- 
    };
    this.squares = createMap(row, column); 
  }
  public String toString() {
    return this.squares + ": " + super.toString();  
  }

}

import javax.swing.*; 
import java.awt.*;
import java.awt.event.*; 

class World extends JComponent implements KeyListener, ActionListener {
  int count;
  public void actionPerformed(ActionEvent e) {
    this.count += 1; 
    System.out.println("Ouch..." + this.count);  
  }
  public void keyPressed(KeyEvent e) { 
    int value = e.getKeyCode();
    System.out.println("Key pressed: " + (char) value); 
    switch (value) {
      // http://docs.oracle.com/javase/6/docs/api/java/awt/event/KeyEvent.html#VK_LEFT
      case KeyEvent.VK_LEFT : 
        this.current.moveLeft(); this.repaint(); 
        System.out.println("Left arrow pressed."); break;
      case KeyEvent.VK_RIGHT: 
        this.current.moveRight(); this.repaint(); 
        System.out.println("Right arrow pressed."); break;
      case KeyEvent.VK_UP   : 
        this.current.moveUp(); this.repaint(); 
        System.out.println("Up arrow pressed."); break;
      case KeyEvent.VK_DOWN : 
        this.current.moveDown(); this.repaint(); 
        System.out.println("Down arrow pressed."); break;
      case KeyEvent.VK_SPACE: System.out.println("Space bar pressed."); break;
      default: System.out.println("Unknown key pressed."); break; 
    }
  }
  public void keyReleased(KeyEvent e) { }
  public void keyTyped(KeyEvent e) { }
  Shape current; 
  Timer timer;
  World() {
    this.timer = new Timer(1000, this); 
    this.current = new TShape(3, 4, this); 
  }
  void start() {
    this.timer.start();  
  }
  public void paintComponent(Graphics g) {
    g.drawString("Welcome to Tetris!", 50, 150);
    this.current.draw(g); 
    System.out.println( current ); 
  }
  static final int ROWS = 22;
  static final int COLS = 10; 
  int squareWidth() { return (int) getSize().getWidth() / World.COLS; }
  int squareHeight() { return (int) getSize().getHeight() / World.ROWS; }
}