From 22c6e38b9215512671328ecbecd4f9e086ea0a67 Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Fri, 24 Nov 2023 10:14:49 +0400 Subject: [PATCH] lab4 some minor fixes --- src/frames/FrameShipsCollection.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/frames/FrameShipsCollection.java b/src/frames/FrameShipsCollection.java index e0b4678..bf5bd1c 100644 --- a/src/frames/FrameShipsCollection.java +++ b/src/frames/FrameShipsCollection.java @@ -188,7 +188,8 @@ public class FrameShipsCollection extends JFrame { pictureBoxCollection.repaint(); } private void buttonTrashClick(){ - if(trashCollection.peek() == null) + DrawingShip ship = trashCollection.pop(); + if(ship == null) return; FrameBattleship form; try { @@ -196,6 +197,6 @@ public class FrameShipsCollection extends JFrame { } catch (IOException e) { throw new RuntimeException(e); } - form.setShip(trashCollection.pop()); + form.setShip(ship); } }