/** * PRG 421 Week 2 * Retail Calculator Application * Greg W. Stuart */ public class RetailCalculator extends JFrame implements ActionListener {
//instance variables for GUI elements private JPanel jPanel1, jPanel2, jPanel3; private JLabel lbTitle, lbItemName, lbDepartment, lbOriginalPrice, lbDiscountRate, lbSalePrice; private JTextField tfItemName, tfOriginalPrice, tfDiscountRate; private JButton btCalculate, btExit, btReset; private JScrollPane jScrollPane; private JTextArea jTextArea; private JComboBox jComboBox; private String strResult; private NumberFormat numberFormat;
//constructor public RetailCalculator {
super("Retail Calculator"); setLayout(null); setSize(415, 440); setLocation(150, 100);
//panels jPanel1 = new JPanel(); jPanel1.setBounds(0, 0, 300, 30); jPanel1.setLayout(new FlowLayout());
jPanel2 = new JPanel(); jPanel2.setBounds(0, 31, 300, 120); jPanel2.setLayout(new GridLayout(6, 2));
jPanel3 = new JPanel(); jPanel3.setBounds(0, 151, 400, 250); jPanel3.setLayout(new GridLayout(1, 1));
//title for pane lbTitle = new JLabel("Retail Calculator");
//label and textfield for employee name lbItemName = new JLabel("Item name: "); lbItemName.setHorizontalAlignment(SwingConstants.RIGHT); tfItemName = new JTextField();