lucasjoshua #16
|
@ -80,13 +80,27 @@ public class BoardDisplay extends JPanel {
|
|||
// }
|
||||
// });
|
||||
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
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (SwingUtilities.isRightMouseButton(e)) {
|
||||
togglePlacementDirection(); // Ausrichtung ändern
|
||||
togglePlacementDirection();
|
||||
} else if (SwingUtilities.isLeftMouseButton(e)) {
|
||||
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() {
|
||||
paintFields();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue