Io And Minesweeper

More I/O

Comma-Separated Values

  • blarg.

Binary Files

  • Primitives stored in native formats
    • Usually using the same format as the computer
    • Not human readable, but efficient.


  • Serializable declares that a class can be serialized (written to binary file)
    public class Species implements Serializable;
        private String name1;
        private int population;
        private double growthRate;
        private transient int tempVar // not serialized

Mine Sweeper

  • Make an array of buttons
 JButton[][] minefield;

How to figure out if a button was pressed, and if so, which button?

  • Event Handler
 actionPerformed( event e )
        Object source = e.getSource();  // pseudo-code
        for(int r=0; r<minefield.length; r++) {
            for (int c = 0; c < minefield[r].length; c++) {
                if (source == minefield[r][c]) {


    public class MineSweeper extends JPanel
        implements ActionListener, MouseListener?, MouseMotionListener?, KeyListener, WindowListener
        public static void main(String[] args)
            JFrame = new JFrame("MineSweeper");
            JFrame.setSize(WIDTH, HEIGHT);

    mineField[r][c] = new JButton("");

    this.setLayout(new GridLayout(3,3));