摇号程序

导入Java . awt . color;

导入Java . awt . event . action event;

导入Java . awt . event . action listener;

导入Java . awt . event . window adapter;

导入Java . awt . event . window event;

导入javax . swing . button group;

导入javax . swing . jbutton;

导入javax . swing . jframe;

导入javax . swing . jlabel;

导入javax . swing . jpanel;

导入javax . swing . jtextfield;

公共类BankWaiting扩展JFrame实现ActionListener {

int total = 0,now = 0;

布尔值is1Ready = false,is2Ready = false,is3Ready = false

int call1,call2,call3

JFrame jf

jlabel jr,JL,jl1,j2,jl2,j3,jl3

JTextField jr4

JButton jb,jb1,jb2,j 1;

JButton工作区1,工作区2,工作区3;

JPanel jp,jp1,jp2

公共银行等待(){

set layout(null);

Jf = new JFrame(“银行调用程序”);//表单

Jr = new JLabel("办理业务请到* *窗口");

jr.setBounds(300,10,800,50);

Jr . set foreground(color . red);

J1 = new JButton("取号");

j 1 . addactionlistener(this);

jr4 = new JTextField(" welcome ");

jr4 . set editable(false);

button group BG = new button group();

BG . add(j 1);

jp = new JPanel();

JL = new JLabel(" 1号窗口");

JL 1 = new JLabel(" 1号窗口,欢迎光临!");

JB = new JButton(" next ");

WorkBut1 = new JButton("开始处理");

workbut 1 . addactionlistener(this);

JB . addactionlistener(this);

jp . set background(color . pink);

jp.setSize(200,80);//大小

jp.setLocation(20,120);//位置

JF . set layout(null);

jp 1 = new JPanel();

J2 =新JLabel(“二号窗口”);

jl2 = new JLabel(" 2号窗口,欢迎光临!");

JB 1 = new JButton(" next ");

WorkBut2 = new JButton("开始处理");

JB 1 . addactionlistener(this);

workbut 2 . addactionlistener(this);

jp 1 . set background(color . pink);

jp1.setSize(200,80);//大小

jp1.setLocation(250,120);//位置

JF . set layout(null);

jp2 = new JPanel();

No.3乐队=新JLabel(“3号窗口”);

jl3 = new JLabel(" 3号窗口,欢迎光临!");

jb2 = new JButton(" next ");

WorkBut3 = new JButton("开始处理");

workbut 3 . addactionlistener(this);

jb2 . addactionlistener(this);

jp2 . set background(color . pink);

jp2.setSize(200,80);//大小

jp2.setLocation(500,120);//位置

JF . set layout(null);

JF . add(jp);

JF . add(jp 1);

JF . add(jp2);

JF . add(Jr);

jp . add(JL);

jp . add(JL 1);

jp . add(JB);

jp . add(workbut 1);

jp 1 . add(J2);

jp 1 . add(jl2);

jp 1 . add(JB 1);

jp 1 . add(work but 2);

jp2 . add(J3);

jp2 . add(jl3);

jp2 . add(jb2);

jp2 . add(workbut 3);

JF . add(j 1);

JF . add(jr4);

j1.setBounds(550,300,60,30);

jr4.setBounds(300,300,200,40);

jf.setSize(800,600);

JF . set visible(true);

JF . addwindowlistener(new window adapter(){

public void window closing(window event e){

system . exit(0);

}

});

}

public void action performed(action event e){

字符串s =

if (e.getSource() == j1) {

S = "Number"+(++total)+",后面是"+(total-now-1)+"客户!";

jr4 . settext(s);

}

if (e.getSource() == jb) {

if (this.hasCustomers()) {

S = "Please"+(++now)+"请到1号窗口办理";

致电1 =现在;

JL 1 . settext(s);

小排版;

is 1 ready = true;

}否则{

S = "目前没有客户";

JL 1 . settext(s);

is 1 ready = false;

}

} else if(e . getsource()= = JB 1){

if (this.hasCustomers()) {

S = "Please"+(++now)+"请到2号窗口办理";

call2 =现在;

jl2 . settext(s);

小排版;

is2Ready = true

}否则{

S = "目前没有客户";

jl2 . settext(s);

is2Ready = false

}

} else if (e.getSource() == jb2) {

if (this.hasCustomers()) {

S = "Please"+(++now)+"请到3号窗口办理";

call3 =现在;

jl3 . settext(s);

小排版;

is3Ready = true

}否则{

S = "目前没有客户";

jl3 . settext(s);

is3Ready = false

}

}

if(e . getsource()= = work but 1){

如果(is1Ready) {

客户s = call1+"正在办理业务。。。";

JL 1 . settext(s);

is 1 ready = false;

}

} else if(e . getsource()= = work but 2){

if (is2Ready) {

客户s = call2+"正在办理业务。。。";

jl2 . settext(s);

is2Ready = false

}

} else if(e . getsource()= = work but 3){

如果(is3Ready) {

客户s = call3+”正在办理业务。。。";

jl3 . settext(s);

is3Ready = false

}

}

}

公共布尔hasCustomers() {

如果(现在& lt总计){

返回true

}否则{

返回false

}

}

公共静态void main(String[] args) {

new bank waiting();

}

}