且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在java awt中使用具有相同标题的多个按钮

更新时间:2022-11-21 18:52:38

当你创建按钮时,你应该在某个地方保留它的引用,这样你就可以测试它在处理程序中的哪个按钮。

When you create the button you should keep its reference somewhere so you can test which button it is in the handler.
Button FoodButton = new Button("DoIt")
Button DrinkButton = new Button("DoIt")