get position of the button on gridlayout
问题 How to get position(I mean row and column) of the clicked button with gridlayout? public void init(final Container pane) { JPanel controls = new JPanel(); int size = (int) Math.sqrt(puzzle.getSize() + 1); controls.setLayout(new GridLayout(size, size)); for (int i = 0; i < puzzle.getSize(); i++) { int k = puzzle.getListItem(i); if (k == puzzle.getEmptyFlag()) controls.add(new JLabel("")); else { JButton jb = new JButton(String.valueOf(k)); jb.addMouseListener(new MouseAdapter() { @Override