Its been awhile since I have toyed around with java, so I'm a bit rusty. But decided to mess with it today.
I have a jPanel that I will be adding objects to, but I want to add the in a new row each time a button is clicked. Anyways the problem is, every time I click the button it resets my integer which I increment.
Here is the snipper:
int row = 0;
row++;
//constraints
GridBagConstraints gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = row;
gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
//add object to panel
jPanel1.add(object, gridBagConstraints);
Basically since I set int row = 0 it resets it to 0 every time I click the button.
Anyone able to offer a quick solution?