Swing 网格布局或 JTable

发布于 2024-08-26 13:13:34 字数 142 浏览 2 评论 0原文

greetngs,我正在尝试通过编写一个简单的 connect4 游戏来学习 Java 和 Swing。

我希望您能指导我解决以下问题:

要模拟 connect4 网格,我应该使用 JTable 还是依赖网格布局?

谢谢。

greetngs, i am trying to learn Java and Swing by writing a simple game of connect4.

i am hoping you could guide me regarding the following issue:

to emulate the connect4 grid should i use a JTable or rely on Grid layout?

thank you.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

离不开的别离 2024-09-02 13:13:34

我认为网格布局会更好
替代文本
(来源:stevemcc.com

网格布局的示例: http://leepoint.net/notes-java/GUI/layouts/30gridlayout.html

您可以使用 JLabel 添加 图像
您可以创建一组 JLabels 并将每个 JLabel 添加到面板的一个单元格中。如果需要修改图片只需修改Jlabel图片即可。

I think Grid layout would be better
alt text
(source: stevemcc.com)

An example of grid layout: http://leepoint.net/notes-java/GUI/layouts/30gridlayout.html

You can use a JLabel to add the images.
You can create an array of JLabels and add each one to one cell of the panel. If you need to modify the picture you just modify the Jlabel picture.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文