Compare commits
3 Commits
864ca20e18
...
7605646b80
Author | SHA1 | Date |
---|---|---|
|
7605646b80 | |
|
5be3f4daf3 | |
|
9e07350f7d |
|
@ -80,13 +80,27 @@ public class BoardDisplay extends JPanel {
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
field.addMouseListener(new MouseAdapter() {
|
field.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseEntered(MouseEvent e) {
|
||||||
|
if (currentShip != null) {
|
||||||
|
previewShipPlacement(x, y, horizontal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseExited(MouseEvent e) {
|
||||||
|
if (currentShip != null) {
|
||||||
|
clearPreview();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
if (SwingUtilities.isRightMouseButton(e)) {
|
if (SwingUtilities.isRightMouseButton(e)) {
|
||||||
togglePlacementDirection(); // Ausrichtung ändern
|
togglePlacementDirection();
|
||||||
} else if (SwingUtilities.isLeftMouseButton(e)) {
|
} else if (SwingUtilities.isLeftMouseButton(e)) {
|
||||||
Point o = new Point(x, y);
|
Point o = new Point(x, y);
|
||||||
handleFieldClick(o); // Linksklick -> Schiff platzieren
|
currentShip.setHorizontal(horizontal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -181,6 +195,7 @@ public class BoardDisplay extends JPanel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
paintFields();
|
paintFields();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue