Class POSFrame
user_interface
java.lang.Object
  java.awt.Component
      java.awt.Container
          java.awt.Window
              java.awt.Frame
                  javax.swing.JFrame
                      user_interface.POSFrame
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, javax.accessibility.Accessible, javax.swing.WindowConstants

public class POSFrame
extends JFrame
This is a sample that was based on the JMCU CashSale component built into the Together tool. This presents a simple GUI and shows how we can tie it into the PD classes.
robustness:
Boundary
subtitle:
The std cashier UI
Stereotype:
ui-component
Author:
TogetherSoft
See Also:  Node Documentation, UI Documentation

Inner classes inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
Inner classes inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
Inner classes inherited from class java.awt.Window
Window.AccessibleAWTWindow
Inner classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
Inner classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
Field Summary
static final int
BorderLayout
BorderLayout
BorderLayout
private ArrayList
cashiers
List of Cashiers
NumberFormat
currencyFormat
Format helper
private CashSale
currentSale
Problem Domain Object
SimpleDateFormat
dateFormat
Format helper
private DMServer
dmServer
Database handle
GridLayout
ImageIcon
JButton
JButton
JButton
JButton
JButton
JLabel
JLabel
JLabel
JLabel
JLabel
JLabel
JLabel
JLabel
JPanel
JPanel
JPanel
JPanel
JScrollPane
JTable
JTextField
JTextField
JTextField
JTextField
JTextField
JTextField
JMenuBar
JMenu
JMenuItem
JMenu
JMenuItem
JMenu
JMenuItem
private int
numCashiers
number of Cashiers
private int
numProducts
number of products for sale
private ArrayList
products
List of store items
static final int
JLabel
JToolBar
static boolean
USE_DB
Use this to trigger the database on/off
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
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
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
Constructor Summary
POSFrame()
Construct the frame
Method Summary
private void
addDetailToTable()
Update the table model to update the table UI.
private void
cancelSale()
User has decided to cancel the scale.
void
void
private void
initButtons()
Keep buttons properly grayed out at the start.
private void
private void
private void
void
void
void
void
void
private void
listAllSales()
List all sales.
private void
loadGUIWithPD()
Load the UI widgets with "data" from the buisness object.
private void
makePayment()
Accept amount of cash paid in, compute change owed.
private void
newSale()
Start off with a fresh CashSale object for the transaction.
private int
private String
removeIllegalChars(String string)
Helper function to strip chars from currency input widget.
private void
scan()
Use this to simulate scanning items
private void
setUpCashiers()
Set up list of cashiers
private void
setUpProducts()
Set up the product "database"
private void
totalSale()
Total all the items in the sale, add in the tax.
void
Field Detail
USE_DB
public static boolean USE_DB = false
Use this to trigger the database on/off

currentSale
private CashSale currentSale = new CashSale()
Problem Domain Object

dmServer
private DMServer dmServer = null
Database handle

products
private ArrayList products
List of store items
See Also:  UI Component

numProducts
private int numProducts = 0
number of products for sale

cashiers
private ArrayList cashiers
List of Cashiers
See Also:  UI Component

numCashiers
private int numCashiers = 0
number of Cashiers

ADDED_DETAIL
static final int ADDED_DETAIL = 0

REMOVED_DETAIL
static final int REMOVED_DETAIL = 1

dateFormat
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd")
Format helper
See Also:  UI Component

currencyFormat
NumberFormat currencyFormat = NumberFormat.getCurrencyInstance()
Format helper
See Also:  UI Component

menuBar1
JMenuBar menuBar1 = new JMenuBar()
See Also:  UI Component

menuFile
JMenu menuFile = new JMenu()
See Also:  UI Component

menuFileExit
JMenuItem menuFileExit = new JMenuItem()
See Also:  UI Component

menuView
JMenu menuView = new JMenu()
See Also:  UI Component

menuViewListAll
JMenuItem menuViewListAll = new JMenuItem()
See Also:  UI Component

menuHelp
JMenu menuHelp = new JMenu()
See Also:  UI Component

menuHelpAbout
JMenuItem menuHelpAbout = new JMenuItem()
See Also:  UI Component

toolBar
JToolBar toolBar = new JToolBar()
See Also:  UI Component

imageHelp
ImageIcon imageHelp

statusBar
JLabel statusBar = new JLabel()
See Also:  UI Component

borderLayout1
BorderLayout borderLayout1 = new BorderLayout()
See Also:  UI Component

jScrollPaneDetails
JScrollPane jScrollPaneDetails = new JScrollPane()
See Also:  UI Component

jTableSaleDetails
JTable jTableSaleDetails = new JTable()
See Also:  UI Component

jPanel1
JPanel jPanel1 = new JPanel()
See Also:  UI Component

borderLayout2
BorderLayout borderLayout2 = new BorderLayout()
See Also:  UI Component

jPanelScan
JPanel jPanelScan = new JPanel()
See Also:  UI Component

jButtonScan
JButton jButtonScan = new JButton()
See Also:  UI Component

jTextFieldItem
JTextField jTextFieldItem = new JTextField()
See Also:  UI Component

jPanelDetails
JPanel jPanelDetails = new JPanel(new GridBagLayout())
See Also:  UI Component

jButtonNewSale
JButton jButtonNewSale = new JButton()
See Also:  UI Component

jButtonCancel
JButton jButtonCancel = new JButton()
See Also:  UI Component

jPanelCompleteSale
JPanel jPanelCompleteSale = new JPanel()
See Also:  UI Component

jButtonPayment
JButton jButtonPayment = new JButton()
See Also:  UI Component

jButtonTotal
JButton jButtonTotal = new JButton()
See Also:  UI Component

borderLayout3
BorderLayout borderLayout3 = new BorderLayout()
See Also:  UI Component

jTextFieldSubTotal
JTextField jTextFieldSubTotal = new JTextField()
See Also:  UI Component

gridLayout1
GridLayout gridLayout1 = new GridLayout()
See Also:  UI Component

jLabel1
JLabel jLabel1 = new JLabel()
See Also:  UI Component

jLabel2
JLabel jLabel2 = new JLabel()
See Also:  UI Component

jTextFieldTax
JTextField jTextFieldTax = new JTextField()
See Also:  UI Component

jLabel3
JLabel jLabel3 = new JLabel()
See Also:  UI Component

jTextFieldPayment
JTextField jTextFieldPayment = new JTextField()
See Also:  UI Component

jTextFieldTotal
JTextField jTextFieldTotal = new JTextField()
See Also:  UI Component

jTextFieldChange
JTextField jTextFieldChange = new JTextField()
See Also:  UI Component

jLabel4
JLabel jLabel4 = new JLabel()
See Also:  UI Component

jLabelCashier
JLabel jLabelCashier = new JLabel()
See Also:  UI Component

jLabel6
JLabel jLabel6 = new JLabel()
See Also:  UI Component

jLabelTimeStamp
JLabel jLabelTimeStamp = new JLabel()
See Also:  UI Component

jLabel8
JLabel jLabel8 = new JLabel()
See Also:  UI Component
Constructor Detail
POSFrame
public POSFrame()
Construct the frame
Method Detail
setUpCashiers
private void setUpCashiers()
Set up list of cashiers

setUpProducts
private void setUpProducts()
Set up the product "database"

initialize
private void initialize()
                 throws Exception

initDatabase
private void initDatabase()

initButtons
private void initButtons()
Keep buttons properly grayed out at the start.

loadGUIWithPD
private void loadGUIWithPD()
Load the UI widgets with "data" from the buisness object.

initDetailTable
private void initDetailTable()

fileExit_actionPerformed
public void fileExit_actionPerformed(ActionEvent e)

viewListAll_actionPerformed
public void viewListAll_actionPerformed(ActionEvent e)

helpAbout_actionPerformed
public void helpAbout_actionPerformed(ActionEvent e)

preCancelCheck
private int preCancelCheck()

cancelSale
private void cancelSale()
User has decided to cancel the scale. Start a new sale.

newSale
private void newSale()
Start off with a fresh CashSale object for the transaction. It will reflect the current timestamp and have no details.

makePayment
private void makePayment()
Accept amount of cash paid in, compute change owed.

totalSale
private void totalSale()
Total all the items in the sale, add in the tax.

scan
private void scan()
Use this to simulate scanning items

listAllSales
private void listAllSales()
List all sales. This should be done using a Table Model... And, it should be done to support numerous data presentations, as there will likely be many more than just "list all."

addDetailToTable
private void addDetailToTable()
Update the table model to update the table UI.

removeIllegalChars
private String removeIllegalChars(String string)
Helper function to strip chars from currency input widget.

jButtonNewSale_actionPerformed
void jButtonNewSale_actionPerformed(ActionEvent e)

jButtonCancel_actionPerformed
void jButtonCancel_actionPerformed(ActionEvent e)

jButtonPayment_actionPerformed
void jButtonPayment_actionPerformed(ActionEvent e)

jButtonTotal_actionPerformed
void jButtonTotal_actionPerformed(ActionEvent e)

jButtonScan_actionPerformed
void jButtonScan_actionPerformed(ActionEvent e)