Class POSFrame
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 |
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 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
USE_DBUse 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 |
Method Summary |
|
|
|
|
|
|
|
|
|
initButtons()Keep buttons properly grayed out at the start. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
loadGUIWithPD()Load the UI widgets with "data" from the buisness object. |
|
makePayment()Accept amount of cash paid in, compute change owed. |
|
newSale()Start off with a fresh CashSale object for the transaction. |
|
|
|
removeIllegalChars(String string)Helper function to strip chars from currency input widget. |
|
scan()Use this to simulate scanning items |
|
|
|
|
|
totalSale()Total all the items in the sale, add in the tax. |
|
|
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
Database handle
products
private ArrayList products
List of store items
numProducts
private int numProducts = 0
number of products for sale
cashiers
private ArrayList cashiers
List of Cashiers
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
currencyFormat
NumberFormat currencyFormat = NumberFormat.getCurrencyInstance()
Format helper
menuBar1
JMenuBar menuBar1 = new JMenuBar()
menuFile
JMenu menuFile = new JMenu()
menuFileExit
JMenuItem menuFileExit = new JMenuItem()
menuView
JMenu menuView = new JMenu()
menuViewListAll
JMenuItem menuViewListAll = new JMenuItem()
menuHelp
JMenu menuHelp = new JMenu()
menuHelpAbout
JMenuItem menuHelpAbout = new JMenuItem()
toolBar
JToolBar toolBar = new JToolBar()
imageHelp
ImageIcon imageHelp
statusBar
JLabel statusBar = new JLabel()
borderLayout1
BorderLayout borderLayout1 = new BorderLayout()
jScrollPaneDetails
JScrollPane jScrollPaneDetails = new JScrollPane()
jTableSaleDetails
JTable jTableSaleDetails = new JTable()
jPanel1
JPanel jPanel1 = new JPanel()
borderLayout2
BorderLayout borderLayout2 = new BorderLayout()
jPanelScan
JPanel jPanelScan = new JPanel()
jButtonScan
JButton jButtonScan = new JButton()
jTextFieldItem
JTextField jTextFieldItem = new JTextField()
jPanelDetails
JPanel jPanelDetails = new JPanel(new GridBagLayout())
jButtonNewSale
JButton jButtonNewSale = new JButton()
jButtonCancel
JButton jButtonCancel = new JButton()
jPanelCompleteSale
JPanel jPanelCompleteSale = new JPanel()
jButtonPayment
JButton jButtonPayment = new JButton()
jButtonTotal
JButton jButtonTotal = new JButton()
borderLayout3
BorderLayout borderLayout3 = new BorderLayout()
jTextFieldSubTotal
JTextField jTextFieldSubTotal = new JTextField()
gridLayout1
GridLayout gridLayout1 = new GridLayout()
jLabel1
JLabel jLabel1 = new JLabel()
jLabel2
JLabel jLabel2 = new JLabel()
jTextFieldTax
JTextField jTextFieldTax = new JTextField()
jLabel3
JLabel jLabel3 = new JLabel()
jTextFieldPayment
JTextField jTextFieldPayment = new JTextField()
jTextFieldTotal
JTextField jTextFieldTotal = new JTextField()
jTextFieldChange
JTextField jTextFieldChange = new JTextField()
jLabel4
JLabel jLabel4 = new JLabel()
jLabelCashier
JLabel jLabelCashier = new JLabel()
jLabel6
JLabel jLabel6 = new JLabel()
jLabelTimeStamp
JLabel jLabelTimeStamp = new JLabel()
jLabel8
JLabel jLabel8 = new JLabel()
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)