public ControllerInputPanel(SudokuModel model, ViewerInputPanel inputPanel) { this.model = model; this.inputPanel = inputPanel; this.board = inputPanel.getBoard(); this.inputPanel.addActionListener(new ClearPress(), inputPanel.getClearButton()); for(ViewerKeyButton k : inputPanel.getKeyButtons()){ this.inputPanel.addActionListener(new KeyClick(inputPanel.getBoard(), k.getLabel()), k); } }
public void setSelectedCell(String label, Position p) { if (!model.isCellGiven(p.getRow(), p.getCol())) { if(!inputPanel.getCandidateButton().isSelected()){ model.setCellNumber(p.getRow(), p.getCol(), Integer.parseInt(label)); board.getSelectedButton().setNumberLabel(label); }else{ if(model.hasCellCandidate(p.getRow(), p.getCol(), Integer.parseInt(label))){ // System.out.println(label); model.removeCellCandidate(p.getRow(), p.getCol(), Integer.parseInt(label)); board.getSelectedButton().setCandidateLabel(model.getCandidates(p.getRow(), p.getCol())); }else{ // System.out.println(label); model.addCellCandidate(p.getRow(), p.getCol(), Integer.parseInt(label)); board.getSelectedButton().setCandidateLabel(model.getCandidates(p.getRow(), p.getCol())); } } } }