Retail Calculator

Only available on StudyMode
  • Topic: Item number, Price
  • Pages : 4 (340 words )
  • Download(s) : 78
  • Published : November 28, 2012
Open Document
Text Preview
package retail.calculator;
import java.awt.*;
import java.awt.event.*;
import java.text.DecimalFormat;
import javax.swing.*;

public class RetailCalculator extends JFrame {
//create ojects
JLabel department;
JLabel number;
JLabel name;
JLabel price;
JLabel discount;
JLabel sale;
JComboBox dept;
JTextField itemNum;
JTextField itemName;
JTextField itemPrice;
JTextField itemDisc;
JTextField salePrice;
JButton calculate;
JButton clear;

public RetailCalculator() {
//set object variables
super("Retail Sales Calculator"); //window title
setSize(250, 250); //set window size
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //window close
GridLayout grid = new GridLayout(7, 2);
setLayout(grid);
department = new JLabel("Department");
dept = new JComboBox();
dept.addItem("Select");
dept.addItem("Apperal");
dept.addItem("Automotive");
dept.addItem("Cosmetics");
dept.addItem("Jewlry");
dept.addItem("Pets");
dept.addItem("Pharmacy");
//add ItemListener...combobox and jtextfield
dept.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent ie) {
String str = (String)dept.getSelectedItem();
itemNum.setText(str);
} //end public void
}); //end item listener
number = new JLabel("Item Number");
itemNum = new JTextField(10);
name = new JLabel("Item Name");
itemName = new JTextField(10);
price = new JLabel("Original Price");
itemPrice = new JTextField(10);
discount = new JLabel("Discount");
itemDisc = new JTextField(10);
sale = new JLabel("Sale Price");...
tracking img