Java - Call Method via JButton

后端 未结 5 1136
生来不讨喜
生来不讨喜 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:53

        btnMyButton.addActionListener(e->{
            JOptionPane.showMessageDialog(null,"Hi Manuel ");
        });
    

    with lambda

提交回复
热议问题