Performing an action when an JMenuItem is clicked?

前端 未结 5 1689
挽巷
挽巷 2021-01-23 02:17

So i have made a simple program with a basic menu at the top of the frame, Now i just need to put actions behind each JMenuItem. Im struggling to work the code out though, Here

5条回答
  •  鱼传尺愫
    2021-01-23 02:24

    You got it working, but you have another problem.

    Don't do this:

    hello.setDefaultCloseOperation(hello.EXIT_ON_CLOSE);
    

    When you close the pop-up frame, your entire JVM terminates. Consult JFrame.setDefaultCloseOperation javadocs for a more appropriate value.

提交回复
热议问题