/** @author Scott Marshall @author University of Glasgow, MSc IT Project 2001 @author Building an OnLine Course in Computing Fundamentals */ package ukacgla_ATT; import javax.swing.border.*; import javax.swing.JTable; import javax.swing.table.AbstractTableModel; import javax.swing.DefaultCellEditor; import javax.swing.JScrollPane; import javax.swing.JFrame; import javax.swing.SwingUtilities; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.table.TableColumn; import java.util.Vector; /** When instantiated, calls abstract mehod createExercise(). createExercise() must generate the JInternal Frames to display the exercise, then create the GUI, then create the truth table and Checker object that verifies the student input. */ public abstract class TableUI extends JFrame{ /** Internal frame to display on Truth table. */ protected JInternalFrame tableFrame; /** Object allows generation of JInternalFrames. */ protected frameMaker gui; /** Object instantiates circuitGrpahics object. */ protected circuitGraphics diagram; /** Hold random numbers used to generate circuit. */ protected TTRandom random; /** Checks answers and provides hints */ protected Checker marker; /** Holds number of rows to be used with the TableModel */ protected int noOfRows; /** Holds the headers for each column */ protected String[] columnNames; /** Holds data displyed through the TableModel */ protected Object[][] data; /** Defines column headers, and used extensively to set the size of the TableModel*/ protected Vector colTitle; /** Holds and presents Truth Table data */ protected MyTableModel myModel; /** Number of columns containing outputs */ protected int noOfOutPuts; //GUI components protected JPanel truthTable,middle,buttonPanel; /** Activate JButton to clear all student input from table */ protected JButton clear; /** Activate JButton to submit student answers for checking */ protected JButton submit; /** Activate JButton to generate next circuit */ protected JButton nextCircuit; /** Array contains JCheckBoxes for selecting individual lines */ protected JCheckBox[] checkBox; /** JCheckBox listener */ protected checkBoxListener listener; /** JTextArea for displaying program output. */ protected JTextArea output; /** contentPane the exercise will be displayed on */ protected Container contentPane; /** Requires a frameMaker object to allow creation of JInternalFrames */ public TableUI(frameMaker g){ gui = g; random = new TTRandom(); //Start random number generation createExercise(); } /** Creates JInternalFrames, mkTable and Checker objects. */ abstract protected void createExercise(); //-------------- INTERACTIVE METHODS ---------------------------- /** Method to compare answers versus real. Each row is checked one row at a time. The results for each row are displayed through the Checker.calcAnswer() method. A JOptionPane provides a visible message to the user as to the overall results. */ public void checkAnswers(){ int i = 0; while (i This method detects strings. */ public boolean testCellsComplete(Object[][] d) { String value; boolean missing = false; try { for (int i=0; i