How can I check that JButton is pressed? If the isEnable() is not work?

前端 未结 6 1522
Happy的楠姐
Happy的楠姐 2020-11-30 14:22

How can I check that JButton is pressed? I know that there is a method that its name is \"isEnabled\"

So I try to write a code to test.

  1. this code have
6条回答
  •  -上瘾入骨i
    2020-11-30 14:44

    Just do System.out.println(e.getActionCommand()); inside actionPerformed(ActionEvent e) function. This will tell you which command is just performed.

    or

    if(e.getActionCommand().equals("Add")){
    
       System.out.println("Add button pressed");
    }
    

提交回复
热议问题