Java - Call Method via JButton

后端 未结 5 1169
生来不讨喜
生来不讨喜 2020-12-31 15:08

How can I call a method by pressing a JButton?

For example:

when JButton is pressed
hillClimb() is called;

I know how to display me

5条回答
  •  滥情空心
    2020-12-31 15:56

    You need to add an event handler (ActionListener in Java) to the JButton.

    This article explains how to do this.

提交回复
热议问题