|
CreditCardPack | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--javax.swing.JComponent
|
+--javax.swing.JPanel
|
+--com.keyoti.creditCard.display.CardElementPanel
Abstract base class for card elements (such as the card number field).
This class enables the simple creation of custom card field elements, suitable for adding
to CreditCardPanel. It provides two JPanels leftPanel and rightPanel, the intention
is that a label indicating the field name will be placed in leftPanel and the data
entry field(s) in rightPanel.
Example:
public class CardNamePanel extends CardElementPanel{
// Labels for the card text field
protected JLabel label = new JLabel("Name on Card:");
// card text field
protected LimitedJTextField cardNameField =
new LimitedJTextField(16, 30);
// The card name last entered into the text field
private String cardName = "";
// Construct a new credit card details panel
public CardNamePanel()
{
label.setFont(labelFont);
cardNameField.setFont(textFieldFont);
cardNameField.addFocusListener(this);
leftPanel.add(label);
rightPanel.add(cardNameField);
}
//required by card element panel
public void setCreditCard(CreditCard card){}
}
Card element components are built around a Swing style 'separable model' architecture, which has it's roots in MVC. The 'seperable model' design combines the view and the controller into one class, leaving the model seperate. http://java.sun.com/products/jfc/tsc/articles/getting_started/getting_started2.html
In this context com.keyoti.creditCard.logic.CreditCard is the model for all the CardElement sub-classes.
| Inner classes inherited from class javax.swing.JPanel |
JPanel.AccessibleJPanel |
| Inner classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent |
| Inner classes inherited from class java.awt.Container |
Container.AccessibleAWTContainer |
| Inner classes inherited from class java.awt.Component |
Component.AccessibleAWTComponent |
| Field Summary | |
protected ElementController |
controller
Controller part of Swing style separable model design (MVC), each sub class of this class should set this field to a sub class of ElementController to control the events and method calls to and from the elements view and model. |
protected JLabel |
label
The field label, that appears in the left panel. |
protected Font |
labelFont
The font used for the labels. |
protected JPanel |
leftPanel
Left JPanel to add components to, for example a JLabel. |
protected PropertyChangeSupport |
pcs
Property change support for sub classes. |
protected JPanel |
rightPanel
Right JPanel to add components to, for example a JTextField. |
protected Font |
textFieldFont
The font used for the text fields. |
| 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 |
| Constructor Summary | |
CardElementPanel()
Construct a new credit card detail element panel |
|
| Method Summary | |
void |
addPropertyChangeListener(PropertyChangeListener l)
Adds the supplied PropertyChangeListener object to registry of objects to be notified of changes to properties in the sub-class. |
protected void |
buildGUI()
Constructs the GUI. |
void |
caretUpdate(CaretEvent e)
Empty caret listener method. |
void |
focusGained(FocusEvent e)
Empty focus listener method |
void |
focusLost(FocusEvent e)
Empty focus listener method |
String |
getLabelText()
Gets the field label text. |
boolean |
getShowDataInputErrors()
Gets whether data input errors should be shown to the user when showDataInputError is called. |
void |
removePropertyChangeListener(PropertyChangeListener l)
Removes the supplied PropertyChangeListener from the registry of objects notified of property changes. |
abstract void |
setCreditCard(CreditCard c)
Sets the credit card used as a model for this view, this method should call setCreditCard in the controller. |
void |
setLabelText(String l)
Sets the field label text to l. |
void |
setShowDataInputErrors(boolean s)
Sets whether data input errors should be shown to the user when showDataInputError is called. |
protected void |
showDataInputError(JComboBox combo,
String message)
If getShowDataInputErrors() == true then displays an error message (in a JOptionPane), requests focus to the errored field. |
protected void |
showDataInputError(JTextField field,
String message,
String correction)
If getShowDataInputErrors() == true then displays an error message (in a JOptionPane), clears the field and requests focus to the errored field. |
protected boolean |
validateFieldForInteger(JTextField field)
Validates a JTextField, checking if its text can be turned into an Integer, returns true if it can, returns false and shows a JOptionPane error if it can't. |
| Methods inherited from class javax.swing.JPanel |
getAccessibleContext,
getUIClassID,
paramString,
updateUI |
| 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.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
| Field Detail |
protected Font labelFont
protected Font textFieldFont
protected transient PropertyChangeSupport pcs
protected JPanel leftPanel
protected JPanel rightPanel
protected ElementController controller
ElementControllerprotected JLabel label
| Constructor Detail |
public CardElementPanel()
pcs != null| Method Detail |
public String getLabelText()
public void setLabelText(String l)
l - the text to appear in the field's label.public void addPropertyChangeListener(PropertyChangeListener l)
l - an object implementing the PropertyChangeListener interface, to be notified of property change events.l != nulll will be notified of property change eventspublic void removePropertyChangeListener(PropertyChangeListener l)
l - an object implementing the PropertyChangeListener interface, will not be notified of property change events in future.l != nulll will not be notified of property change eventspublic void focusLost(FocusEvent e)
public void focusGained(FocusEvent e)
public abstract void setCreditCard(CreditCard c)
setCreditCard in the controller.ElementControllerpublic void caretUpdate(CaretEvent e)
public void setShowDataInputErrors(boolean s)
s - true if data input errors should be shown, false otherwise.getShowDataInputErrors() == spublic boolean getShowDataInputErrors()
protected void showDataInputError(JTextField field,
String message,
String correction)
field - the JTextField that the erroroneous data was entered into.message - the String to be shown to the user.correction - the String to be put in the text field as a correction.field, message or correction is nullfield != null AND message != null AND correction != nullJOptionPane indicating error is displayed with focus if getShowDataInputErrors() == true else does nothing
protected void showDataInputError(JComboBox combo,
String message)
combo - the JComboBox that the erroroneous data was selected in.message - the String to be shown to the user.combo or message is nullcombo != null AND message != nullJOptionPane indicating error is displayed with focus if getShowDataInputErrors() == true else does nothingprotected boolean validateFieldForInteger(JTextField field)
field - the JTextField that the text originated in.field is nullfield != nullreturn == (true AND new Integer(field.getText() !-> NumberFormatException)) OR(false AND showDataInputError is called)protected void buildGUI()
getComponent(getComponentCount()-1) == x ANDx.getComponent(x.getComponentCount()-2) == leftPanel ANDx.getComponent(x.getComponentCount()-1) == rightPanel
|
CreditCardPack | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||