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); 展开
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); 展开
4个回答
展开全部
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~ 特此感谢感谢感谢之。
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~ 特此感谢感谢感谢之。
展开全部
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~ 特此感谢感谢感谢之。
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~ 特此感谢感谢感谢之。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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~
特此感谢感谢感谢之。
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~
特此感谢感谢感谢之。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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]);
}
Button[] b=new Button[strs.length];
for(int i=0;i<strs.length;i++){
b[i]=new Button(strs[i]);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询