swoop

Highlight Listener

May 9th, 2012
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. class HighlightListener extends MouseAdapter{
  2.        
  3.         private Cell[] highlighted = new Cell[c.getSize()];
  4.        
  5.         public void mouseClicked(MouseEvent e){
  6.        
  7.             Cell cell = new Cell();
  8.             cell = (Cell) e.getSource();
  9.  
  10.             if(cell.getAcross() != null && !cell.isHighlight()){
  11.                 if(highlighted[0] != null){
  12.                     for(Cell c : highlighted){
  13.                         c.setHighlight(false);
  14.                     }
  15.                 }
  16.                
  17.                 Clue clue = cell.getAcross();
  18.                 highlighted = clue.getCellsInRange().clone();
  19.                 for(Cell c : highlighted){
  20.                     c.setHighlight(true);
  21.                 }
  22.  
  23.             } else {
  24.                 if(cell.getDown() != null){
  25.                     if(highlighted[0] != null){
  26.                         for(Cell c : highlighted){
  27.                             c.setHighlight(false);
  28.                         }
  29.                     }
  30.                     Clue clue = cell.getDown();
  31.                     highlighted = clue.getCellsInRange().clone();
  32.                     for(Cell c : highlighted){
  33.                         c.setHighlight(true);
  34.                     }
  35.  
  36.                 }
  37.             }
  38.             repaint();
  39.         }
  40.     }
Advertisement
Add Comment
Please, Sign In to add comment