資源簡介
這是我用Java編寫的商場收銀系統(tǒng),希望各位評價,指正。
代碼片段和文件信息
import?java.awt.*;
import?java.awt.event.*;
import?javax.swing.*;
import?javax.swing.border.*;
public?class?YSystem?extends?frame{
Box?box1?box2?box3?box4;
Label?label1?label2?label3?label4?label5;
TextField?tf1tf2;
JComboBox?combox;
Button?button1button2button3;
ScrollPane?spanel;
TextArea?text;
Panel?panel;
String?op[]={“正常收費““打八折““打七折““打五折““滿300返100“};
double?sum;
YSystem(String?s){
super();
settitle(s);
label1=new?Label(“單價:“);
label2=new?Label(“數(shù)量:“);
label3=new?Label(“收費方式:“);
box1=Box.createVerticalBox();
box1.add(label1);
box1.add(label2);
box1.add(label3);
tf1=new?TextField();
tf1.setForeground(Color.red);
tf2=new?TextField();
tf2.setForeground(Color.red);
combox=new?JComboBox(op);
box2=Box.createVerticalBox();
box2.add(tf1);
box2.add(tf2);
box2.add(combox);
button1=new?Button(“確定“);
button2=new?Button(“重置“);
button3=new?Button(“退出“);
box3=Box.createVerticalBox();
box3.add(button1);
box3.add(button2);
box3.add(button3);
box4=Box.createHorizontalBox();
box4.add(box1);
box4.add(box2);
box4.add(box3);
text=new?TextArea(615);
text.setEditable(false);
text.setFont(new?Font(“烏龍絞柱“Font.BOLD+Font.ITALIC22));
text.setBackground(Color.cyan);
spanel=new?ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
spanel.add(text);
label4=new?Label(“總計:“);
Font?f=new?Font(““Font.BOLD25);
label4.setFont(f);
label4.setForeground(Color.red);
label5=new?Label(“????????????????????????????????“);
label5.setFont(new?Font(“隸書“Font.BOLD18));
panel=new?Panel();
panel.add(label4);
panel.add(label5);
add(BorderLayout.NORTHbox4);
add(BorderLayout.CENTERtext);
add(BorderLayout.SOUTHpanel);
button3.addActionListener(new?ActionListener(){
@Override
public?void?actionPerformed(ActionEvent
評論
共有 條評論