import java.awt.Button;
import java.awt.Label;
import java.awt.TextArea;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
public class paylist implements ActionListener {
private JFrame payFrame;
private TextField wareTxt, numTxt, payTxt;
private TextArea wareList;
private Button appendBtn, sureBtn, cancelBtn, payBtn,pay1Btn, manageBtn, closeBtn,helpBtn;
private Label suoxuan, geshu,fukuan;
private String[] ware;
private double[] warePrice;
private double amountToPrice;
private double payMoney, backMoney;
private int front, rear;
private frame frame;
public paylist(){
ware = new String[50];
warePrice = new double[50];
payFrame = new JFrame("超市收银");
suoxuan = new Label("所选商品");
geshu = new Label("商品个数");
fukuan = new Label("付款金额:");
wareTxt = new TextField(10);
numTxt = new TextField(3);
payTxt = new TextField();
wareList = new TextArea();
appendBtn = new Button("添加");
sureBtn = new Button("确认");
cancelBtn = new Button("完成");
payBtn = new Button("付款");
pay1Btn = new Button("收银结算");
manageBtn = new Button("添加商品种类");
helpBtn = new Button("帮助");
closeBtn = new Button("退出");
appendBtn.addActionListener(this);
sureBtn.addActionListener(this);
cancelBtn.addActionListener(this);
payBtn.addActionListener(this);
pay1Btn.addActionListener(this);
manageBtn.addActionListener(this);
helpBtn.addActionListener(this);
closeBtn.addActionListener(this);
payFrame.setLayout(null);
payFrame.add(wareTxt);
payFrame.add(numTxt);
payFrame.add(wareList);
payFrame.add(appendBtn);
payFrame.add(sureBtn);
payFrame.add(cancelBtn);
payFrame.add(suoxuan);
payFrame.add(geshu);
payFrame.add(fukuan);
payFrame.add(pay1Btn);
payFrame.add(payBtn);
payFrame.add(manageBtn);
payFrame.add(closeBtn);
payFrame.add(helpBtn);
payFrame.setLocation(350, 200);
payFrame.setSize(430,400);
suoxuan.setBounds(40, 50, 100, 20);
geshu.setBounds(150, 50, 100, 20);
fukuan.setBounds(30, 330,50,20);
wareTxt.setBounds(40, 70, 100, 20);
numTxt.setBounds(160, 70, 50, 20);
payTxt.setBounds(90, 330, 60, 20);
wareList.setBounds(40, 100, 240, 200);
appendBtn.setBounds(230, 70, 50, 20);
sureBtn.setBounds(180, 325, 50, 30);
cancelBtn.setBounds(250, 325, 50, 30);
payBtn.setBounds(180, 325, 50, 30);
manageBtn.setBounds(10, 2, 80, 30);
pay1Btn.setBounds(110, 2, 80, 30);
helpBtn.setBounds(210, 2, 80, 30);
closeBtn.setBounds(310, 2, 80, 30);
payFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void init(){
wareTxt.setText("");
numTxt.setText("");
}
public void AppendList(String wareName){
for(int i=0;i<rear;i++){
if(ware[i].equals(wareName)){
wareList.append(ware[i]+" 数量:"+numTxt.getText()+"单价:"+warePrice[i]+"\n");
amountToPrice += warePrice[i]*Integer.parseInt(numTxt.getText()); //String 转换 int
return;
}
}
wareList.append("没有找到该商品\n");
}
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource() == appendBtn){
AppendList(wareTxt.getText());
init();
}
else if(e.getSource() == sureBtn){
wareList.append("总计金额: "+amountToPrice+"\n");
payFrame.add(payTxt);
payFrame.remove(sureBtn);
payFrame.add(payBtn);
}
else if(e.getSource() == cancelBtn){
payFrame.setVisible(false);
frame.setframe(true);
init();
}else {
payMoney = Double.parseDouble(payTxt.getText());
backMoney = payMoney - amountToPrice;
wareList.append("付款金额:"+payMoney+" 找赎:"+backMoney+"\n谢谢惠顾");
payFrame.remove(payBtn);
payFrame.remove(payTxt);
payFrame.add(sureBtn);
}
}
public void setWare(String ware) {
this.ware[rear] = ware;
}
public void setWarePrice(double warePrice) {
this.warePrice[rear] = warePrice;
}
public void setRear(int rear) {
this.rear += rear;
}
public void setPayFrame(boolean arg0) {
this.payFrame.setVisible(arg0);
}
public void setframe(frame frame) {
this.frame = frame;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
非常简单的JAVA编辑商场收银系统
共27个文件
java:6个
class:6个
prefs:3个
4星 · 超过85%的资源 需积分: 10 30 下载量 20 浏览量
2010-03-19
13:11:28
上传
评论 1
收藏 18KB RAR 举报
温馨提示
此为JAVA菜鸟入门新作. 适合初学着下载参考. JAVA商场简易收银系统.有待完善.
资源推荐
资源详情
资源评论
收起资源包目录
market.rar (27个子文件)
market
.project 382B
bin
str.class 2KB
data.class 902B
frame.class 2KB
shouqian.class 807B
paylist.class 5KB
addgoods.class 3KB
.metadata
version.ini 26B
.lock 0B
.plugins
org.eclipse.ui.ide
org.eclipse.jdt.launching
libraryInfos.xml 2KB
org.eclipse.team.cvs.ui
org.eclipse.team.cvs.core
.running 0B
org.eclipse.core.resources
.safetable
org.eclipse.core.resources 116B
.snap 201B
.root
.properties 17KB
.markers.snap 16B
.projects
.history
.index 33KB
org.eclipse.ui
org.eclipse.ui.workbench
org.eclipse.core.runtime
.settings
org.eclipse.ui.prefs 79B
org.eclipse.jdt.core.prefs 129B
org.eclipse.jdt.launching.prefs 439B
org.eclipse.jdt.core
org.eclipse.debug.ui
org.eclipse.debug.core
org.eclipse.jdt.ui
src
shouqian.java 468B
data.java 347B
str.java 709B
addgoods.java 3KB
paylist.java 4KB
frame.java 2KB
.classpath 232B
build.xml 3KB
共 27 条
- 1
资源评论
- amputer2013-11-28做课程设计下载来参考的,虽然实现的功能和我的要求有点不一样,有一点bug,但是还是很不错。
dog711718
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功