Java Grid,每个按钮带有按钮+ ID [英] Java Grid with button + id to each button
本文介绍了Java Grid,每个按钮带有按钮+ ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在一个充满按钮的JPanel中创建一个网格,然后我想在一个循环中创建它们,因为我大约有100个按钮.创建的每个按钮必须具有不同的ID看我的照片以更好地了解:s
I'd like to make a grid in a JPanel full of buttons, then i want to create them in a loop because i've aproximatly 100 buttons. Each button created must have an id differents see my picture to understand better :s
我认为我必须创建这样的方法,但是我不知道如何进行操作:
I think I have to create a method like this but I don't know how to proceed :
public Button(String text , int id){
//code
}
然后将其添加到循环中以创建网格:)
And then add it to a loop to create the grid :)
如果有人可以帮助我,将不胜感激!;)
if anyone can help me it would be very appreciated ! ;)
推荐答案
每个 GridButton
知道它在网格上的位置."完整的示例显示了如何在循环中创建按钮以及如何在 List< GridButton>
.
这篇关于Java Grid,每个按钮带有按钮+ ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文