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