我基本上只想制作一个JOptionPane窗口,该窗口顶部有一个数字,并且如果我按这些按钮之一,则有2个按钮 +1和 -1,上面的数字应该减少或增加1。如果有人可以帮助我发布代码或向我解释如何做,那就非常好。谢谢
Hi I basically just want to make a JOptionPane window which has a number on top and 2 Buttons "+1" and "-1" if i press one of these Buttons the Number above should Decrease or Increase by 1. It would be very nice if someone could help me with posting a code or explaining how to make it to me. Thanks
推荐答案我将创建一个包含3个组件,一个JLabel和两个JButton的简单JDialog。将ActionListeners添加到每个按钮以加1或减1。
I would just create a simple JDialog with 3 components, a JLabel and two JButtons. Add ActionListeners to each of the buttons to either add 1 or subtract one.
首先阅读 Swing教程。也许有关如何使用按钮和如何使用布局管理器的部分。
Start by reading the Swing tutorial. Maybe the section on How to Use Buttons and How to Use Layout Managers.
如果遇到问题,请发布 SSCCE ,其中显示了您的操作。
If you have problems then post your SSCCE that shows what you have done.
更多推荐
制作一个简单的Java OptionPane计数器
发布评论