Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
嗨,我基本上只想制作一个 JOptionPane 窗口,顶部有一个数字和 2 个按钮“+1”和“-1”,如果我按下这些按钮之一,上面的数字应该减少或增加 1。这会很好如果有人可以帮助我发布代码或向我解释如何制作它。谢谢
我将创建一个包含 3 个组件、一个 JLabel 和两个 JButton 的简单 JDialog。将 ActionListeners 添加到每个按钮以加 1 或减 1。
从阅读Swing 教程开始。也许关于How to Use Buttons和的部分How to Use Layout Managers。
How to Use Buttons
How to Use Layout Managers
如果您有问题,请发布您的SSCCE,以显示您已完成的工作。