问题
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