Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. for (Node node : officeHoursGridPane.getChildren()) {
  2. node.setOnMouseEntered((MouseEvent t) -> {
  3. node.setStyle("-fx-background-color:#f9f3c5;");
  4. Node source = (Node)t.getSource();
  5. Integer colIndex = GridPane.getColumnIndex(source);
  6. Integer rowIndex = GridPane.getRowIndex(source);
  7. //ystem.out.println("Collumn #: " + colIndex + "nRow #: " + rowIndex);
  8. for(int c = 0; c <= colIndex; c++){
  9. Node[] colNode = getNodeByColumnIndex(colIndex, officeHoursGridPane);
  10. int colCount=0;
  11. for(int v = 0; v <= colNode.length; v++){
  12. Node vertNode = colNode[v];
  13. vertNode.setStyle("-fx-background-color:#f9f3c5;");
  14. }
  15. }
  16. });
  17. node.setOnMouseExited((MouseEvent t) -> {
  18. node.setStyle("-fx-background-color:#ffffff;");
  19. });
  20. }
  21.  
  22. public Node[] getNodeByColumnIndex (final int column, GridPane gridPane) {
  23. Node[] result = null;
  24. ObservableList<Node> childrens = gridPane.getChildren();
  25. int count = 0;
  26. for (Node node : childrens) {
  27. if(GridPane.getColumnIndex(node) == column) {
  28. result[count] = node;
  29. count++;
  30. if(count > column){
  31. break;
  32. }
  33. }
  34. }
  35.  
  36. return result;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement