1 year ago

#379963

test-img

The Bromie

I want to hardcode numbers into an ActionListener without using the actual variable

for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            visBoard[i][j] = new JButton();
            visBoard[i][j].addActionListener(e -> playTurn(i, j));
            moveSltPnl.add(visBoard[i][j]);
        }
}

Basically, I want to make the actionListener use the value of the variable, but not the actual variable itself

java

swing

jpanel

jbutton

actionlistener

0 Answers

Your Answer

Accepted video resources