public void mouseClicked(MouseEvent e) { Coordinate coordinate = new Coordinate(e); for (Icon icon : Screen.frame.desktopIcons) { if (e.getX() > icon.getLocation().getX()) { if (e.getY() > icon.getLocation().getY()) { if (e.getX() < icon.getLocation().getX() + 50) { if (e.getY() < icon.getLocation().getY() + 50) { icon.clickEvent(coordinate); } else { icon.nullEvent(coordinate); } } else { icon.nullEvent(coordinate); } } else { icon.nullEvent(coordinate); } } else { icon.nullEvent(coordinate); } } for (Window window : Screen.frame.openWindows) { if (e.getX() > window.getLocation().getX()) { if (e.getY() > window.getLocation().getY()) { if (e.getX() < window.getLocation().getX() + window.getSize().width) { if (e.getY() < window.getLocation().getY() + window.getSize().height) { window.clickEvent(new Coordinate(e)); } else { window.nullEvent(coordinate); } } else { window.nullEvent(coordinate); } } else { window.nullEvent(coordinate); } } else { window.nullEvent(coordinate); } } Screen.frame.repaint(); }
public void mouseDragged(MouseEvent e) { Coordinate coordinate = new Coordinate(e); for (Window window : Screen.frame.openWindows) { if (e.getX() > window.getLocation().getX()) { if (e.getY() > window.getLocation().getY()) { if (e.getX() < window.getLocation().getX() + window.getSize().width) { if (e.getY() < window.getLocation().getY() + window.getSize().height) { window.dragEvent( new Coordinate( e.getX() - ((window.getSize().width / 2)), e.getY() - ((window.getSize().height / 2)))); } else { window.nullEvent(coordinate); } } else { window.nullEvent(coordinate); } } else { window.nullEvent(coordinate); } } else { window.nullEvent(coordinate); } } Screen.frame.repaint(); }