在按钮中插入字符数组
我试图将字母表放在不同的按钮中,但我无法使其工作。我的代码如下所示:
char[] Letter = {'a','b','c','d','e','f','g','h'
,'i','j','k','l','m','n','o','p','q'
,'r','s','t','u','v','w','x','y','z'};
Button[] But;
for (int i = 0; i <= 26; ++i) {
But = new Button(Letter[i]);
this.add(But[i], BorderLayout.SOUTH);
}
I'm trying to put the alphabet in different buttons, but I cant make it work. My code looks like this:
char[] Letter = {'a','b','c','d','e','f','g','h'
,'i','j','k','l','m','n','o','p','q'
,'r','s','t','u','v','w','x','y','z'};
Button[] But;
for (int i = 0; i <= 26; ++i) {
But = new Button(Letter[i]);
this.add(But[i], BorderLayout.SOUTH);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这应该对你有用。 Java 中的约定是以小写字母开头命名变量。
This should work for you. Its convention in Java to name variables starting with a lower case letter.
你可能想要这个
而不是这个
You probably wanted this
instead of this