java 如何将下列按钮用按钮数组和for循环表现出来,并且添加按纽监听器!

b0=newButton("Backspace");b0.addActionListener(this);b1=newButton("CE");b1.addActionL... b0 = new Button("Backspace");
b0.addActionListener(this);
b1 = new Button("CE");
b1.addActionListener(this);
b2 = new Button("C");
b2.addActionListener(this);
b3 = new Button("MC");
b3.addActionListener(this);
b4 = new Button("MR");
b4.addActionListener(this);
b5 = new Button("MS");
b5.addActionListener(this);
b6 = new Button("M+");
b6.addActionListener(this);
b7 = new Button("7");
b7.addActionListener(this);
b8 = new Button("8");
b8.addActionListener(this);
b9 = new Button("9");
b9.addActionListener(this);
b10 = new Button("/");
b10.addActionListener(this);
b11 = new Button("平方根");
b11.addActionListener(this);
b12 = new Button("4");
b12.addActionListener(this);
b13 = new Button("5");
b13.addActionListener(this);
b14 = new Button("6");
b14.addActionListener(this);
b15 = new Button("*");
b15.addActionListener(this);
b16 = new Button("平方");
b16.addActionListener(this);
b17 = new Button("1");
b17.addActionListener(this);
b18 = new Button("2");
b18.addActionListener(this);
b19 = new Button("3");
b19.addActionListener(this);
b20 = new Button("-");
b20.addActionListener(this);
b21 = new Button("立方");
b21.addActionListener(this);
b22 = new Button("0");
b22.addActionListener(this);
b23 = new Button("+/-");
b23.addActionListener(this);
b24 = new Button(".");
b24.addActionListener(this);
b25 = new Button("+");
b25.addActionListener(this);
b26 = new Button("=");
b26.addActionListener(this);
展开
 我来答
ZoviKoo
推荐于2016-01-21 · TA获得超过293个赞
知道小有建树答主
回答量:155
采纳率:0%
帮助的人:165万
展开全部
String[] strs ={"Backspace","CE","C","MC","1","2","3","4","5","6","7","8","9"};
Button[] b=new Button[strs.length];
for(int i=0;i<strs.length;i++){
b[i]=new Button(strs[i]);
b[i].addActionListener(this);
}

按钮数组其实这里都不需要 写法如下
String[] strs={"Backspace","CE","C","MC","1","2","3","4","5","6","7","8","9"};
for(int i=0;i<strs.length;i++){
(new Button(strs[i])).addActionListener(this);
}

字符串内容来源niubore~ 特此感谢感谢感谢之。
郭某人来此
2015-10-07 · TA获得超过1646个赞
知道答主
回答量:952
采纳率:100%
帮助的人:90.9万
展开全部
String[] strs ={"Backspace","CE","C","MC","1","2","3","4","5","6","7","8","9"};
Button[] b=new Button[strs.length];
for(int i=0;i<strs.length;i++){
b[i]=new Button(strs[i]);
b[i].addActionListener(this);
}

按钮数组其实这里都不需要 写法如下
String[] strs={"Backspace","CE","C","MC","1","2","3","4","5","6","7","8","9"};
for(int i=0;i<strs.length;i++){
(new Button(strs[i])).addActionListener(this);
}

字符串内容来源niubore~ 特此感谢感谢感谢之。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
裘初资思恩
2019-07-20 · TA获得超过3834个赞
知道大有可为答主
回答量:3167
采纳率:34%
帮助的人:211万
展开全部
String[]
strs
={"Backspace","CE","C","MC","1","2","3","4","5","6","7","8","9"};
Button[]
b=new
Button[strs.length];
for(int
i=0;i<strs.length;i++){
b[i]=new
Button(strs[i]);
b[i].addActionListener(this);
}
按钮数组其实这里都不需要
写法如下
String[]
strs={"Backspace","CE","C","MC","1","2","3","4","5","6","7","8","9"};
for(int
i=0;i<strs.length;i++){
(new
Button(strs[i])).addActionListener(this);
}
字符串内容来源niubore~
特此感谢感谢感谢之。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
niubore
2010-02-07 · TA获得超过856个赞
知道小有建树答主
回答量:293
采纳率:0%
帮助的人:307万
展开全部
String[] strs={"Backspace","CE","C","MC","1","2","3","4","5","6","7","8","9"};
Button[] b=new Button[strs.length];
for(int i=0;i<strs.length;i++){
b[i]=new Button(strs[i]);
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式