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); } }