You need to write a method that, when you click on JPanel, first write to a variable unit, when pressed again, record 0, again, write one again, and so on ... Help to implement)

  • one
    Your question fully describes the algorithm of actions. What you can not do? - ReinRaus
  • The algorithm is described, but I ask for help in the syntax itself, I do not know with what tools to implement it - Artyom Gribkov

1 answer 1

private int val = 0; ... public void switchVal() { val = 1 - val; }