org.concord.pedagogica.ui
Class TableInputView

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--org.concord.pedagogica.ui.TableInputView
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, javax.swing.event.CaretListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable

public class TableInputView
extends javax.swing.JPanel
implements java.beans.PropertyChangeListener, java.awt.event.ActionListener, javax.swing.event.CaretListener

Class that generates an n x n table for use as a Punnett Square.

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TableInputView()
          Constructor with no arguments.
TableInputView(int size)
          Constructor that allows user to provide an argument to set the size of the Punnett Square table.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
           
 void addActionListener(java.awt.event.ActionListener listener)
           
 void caretUpdate(javax.swing.event.CaretEvent event)
           
 void clearAllText()
          A method which can be applied to every cell in a Punnett Square or TableInputView object.
 java.awt.Point findCellLocation(java.lang.Object cell)
          Method that determines the upper lefthand point location of an individual cell in the table that has experienced a mouse press.
 TableInputModel getTableInputModel()
          Method which returns the associated TableInputModel that e.g.
 int getTableSize()
           
 void initialize()
          Method that: provides the table with resizing capability and listens for a mouse press for table cell selection.
 boolean isCellEditable(int row, int col)
           
 boolean isCellSelectable(int row, int col)
           
 boolean isCellSelected(int row, int col)
           
static void main(java.lang.String[] args)
           
 void mousePressed(java.awt.event.MouseEvent evt)
          Event handler that
protected  void notifyActionListeners()
           
 void paintComponent(java.awt.Graphics g)
           
 void propertyChange(java.beans.PropertyChangeEvent event)
           
 void removeActionListener(java.awt.event.ActionListener listener)
           
 void setAllEditable(boolean editable)
          A boolean method which can be applied to every cell in a Punnett Square or TableInputView object.
 void setAllSelectable(boolean selectable)
           
 void setAllSelected(boolean selected)
           
 void setBackground(java.awt.Color color)
          To set the background color of the Punnett Square.
 void setCellEditable(boolean editable, int row, int col)
          A boolean method which can be applied to individual cells in a Punnett Square or TableInputView object.
 void setCellSelectable(boolean selectable, int row, int col)
           
 void setCellSelected(boolean selected, int row, int col)
          A boolean method which can be applied to individual cells in a Punnett Square or TableInputView object.
 void setCellText(java.lang.String text, int row, int col)
          A method which can be applied to individual cells in a Punnett Square or TableInputView object.
 void setTableInputModel(TableInputModel model)
          Method which associates a particular TableInputModel with a TableInputView object.
 void setTableSize(int size)
           
 void setTableSize(int size, java.lang.String breakChars)
          Method to set the Punnett Square table size.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TableInputView

public TableInputView()
Constructor with no arguments.

TableInputView

public TableInputView(int size)
Constructor that allows user to provide an argument to set the size of the Punnett Square table.

Parameters:
size - int size size of n x n table
Method Detail

initialize

public void initialize()
Method that: provides the table with resizing capability and listens for a mouse press for table cell selection.

setBackground

public void setBackground(java.awt.Color color)
To set the background color of the Punnett Square. Example: table.setBackground(Color.pink); will give the Punnett Square or TableInputView object table a background color of pink.
Overrides:
setBackground in class javax.swing.JComponent

setTableSize

public void setTableSize(int size)

setTableSize

public void setTableSize(int size,
                         java.lang.String breakChars)
Method to set the Punnett Square table size.
Parameters:
size - int size Example: table.setTableSize(3); will give the Punnett Square or TableInputView object table a size of 3 cells per row and 3 cells per column.

getTableSize

public int getTableSize()

paintComponent

public void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

findCellLocation

public java.awt.Point findCellLocation(java.lang.Object cell)
Method that determines the upper lefthand point location of an individual cell in the table that has experienced a mouse press.

Parameters:
cell - Object cell cell is assigned an array location
Returns:
new Point (i, j)

mousePressed

public void mousePressed(java.awt.event.MouseEvent evt)
Event handler that

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

caretUpdate

public void caretUpdate(javax.swing.event.CaretEvent event)
Specified by:
caretUpdate in interface javax.swing.event.CaretListener

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

getTableInputModel

public TableInputModel getTableInputModel()
Method which returns the associated TableInputModel that e.g. contains the text entered into each Punnett Square cell. Example: table.getTableInputModel().getCellText(1, 1); will get the text that resides in the Punnett Square cell located in row 2 and col 2 (cells are numbered from 0 going from left to right and from top to bottom) of the TableInputView object table.

setTableInputModel

public void setTableInputModel(TableInputModel model)
Method which associates a particular TableInputModel with a TableInputView object. Example: table.setTableInputModel(modelname);

setAllEditable

public void setAllEditable(boolean editable)
A boolean method which can be applied to every cell in a Punnett Square or TableInputView object. Example: table.setEditable(false); will disallow any text changes to any of the cells in the TableInputView object called table.

Parameters:
editable - boolean - editable setting the JTextField to be editable either true or false

setCellEditable

public void setCellEditable(boolean editable,
                            int row,
                            int col)
A boolean method which can be applied to individual cells in a Punnett Square or TableInputView object. Example: table.setEditable(false, 0, 1); will disallow any text changes to the cell located in row 1 and column 2 (cells are numbered from 0 going from left to right and from top to bottom) of the TableInputView object called table.

Parameters:
editable - boolean editable setting the JTextField to be editable either true or false
col - int col number of the column in the table starting at the far left with column 0 (zero)

isCellEditable

public boolean isCellEditable(int row,
                              int col)

setCellSelected

public void setCellSelected(boolean selected,
                            int row,
                            int col)
A boolean method which can be applied to individual cells in a Punnett Square or TableInputView object. Example: table.setCellSelected(false, 0, 1); will select the cell located in row 1 and column 2 (cells are numbered from 0 going from left to right and from top to bottom) of the TableInputView object called table.

Parameters:
editable - boolean editable setting the Cell to be selected either true or false
col - int col number of the column in the table starting at the far left with column 0 (zero)

isCellSelected

public boolean isCellSelected(int row,
                              int col)

isCellSelectable

public boolean isCellSelectable(int row,
                                int col)

setCellSelectable

public void setCellSelectable(boolean selectable,
                              int row,
                              int col)

setAllSelected

public void setAllSelected(boolean selected)

setAllSelectable

public void setAllSelectable(boolean selectable)

addActionListener

public void addActionListener(java.awt.event.ActionListener listener)

removeActionListener

public void removeActionListener(java.awt.event.ActionListener listener)

notifyActionListeners

protected void notifyActionListeners()

setCellText

public void setCellText(java.lang.String text,
                        int row,
                        int col)
A method which can be applied to individual cells in a Punnett Square or TableInputView object. Example: table.setCellText("Hello", 0, 1); will set the text of the cell located in row 1 and column 2 (cells are numbered from 0 going from left to right and from top to bottom) of the TableInputView object called table.

Parameters:
editable - boolean editable setting the Cell to be selected either true or false
col - int col number of the column in the table starting at the far left with column 0 (zero)

clearAllText

public void clearAllText()
A method which can be applied to every cell in a Punnett Square or TableInputView object. Example: table.clearAlltext(); will set all text fields of the cells in the TableInputView object called table to the empty string.

Parameters:
editable - boolean - editable setting the JTextField to be editable either true or false

main

public static void main(java.lang.String[] args)