Make a simple Java OptionPane Counter

假装没事ソ 提交于 2019-12-13 07:23:43

问题


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


回答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.

Start by reading the Swing tutorial. Maybe the section on How to Use Buttons and How to Use Layout Managers.

If you have problems then post your SSCCE that shows what you have done.



来源:https://stackoverflow.com/questions/19687480/make-a-simple-java-optionpane-counter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!