如何使用循环制作大量具有不同名称的 JButtons / JLabels?

发布于 2025-01-13 20:17:58 字数 207 浏览 4 评论 0原文

我将如何创建大量的 JButton 和 JLable 而不必声明一长串,我不知道如果我做了一个 for 循环,例如“for (int I = 0; I < 30; I++) { JButton 按钮 = new JButton(); 虽然这会创建许多按钮,但我希​​望稍后能够单独编辑每个按钮,那么我将如何执行这个按钮循环,但它们都有不同的名称。 非常感谢任何帮助:)

How would I go about creating lots of JButtons and JLables without having to declare a long list of them , I'm not sure how to do it if I made a for loop which said e.g. "for (int I = 0; I < 30; I++) { JButton button = new JButton(); }
Although this would create many buttons I want to be able to individually edit each button later on so how would I do this loop of buttons but them all having different names.
Any help is very much appreciated :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文