From 59c5a52675606d149d6a4cc2fb80ac004f834f24 Mon Sep 17 00:00:00 2001 From: Ivan_Starostin Date: Fri, 22 Dec 2023 20:13:55 +0400 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=BB=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD=D0=BE=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frames/FrameLainer.java | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/frames/FrameLainer.java b/src/frames/FrameLainer.java index 808d4f1..4915e9b 100644 --- a/src/frames/FrameLainer.java +++ b/src/frames/FrameLainer.java @@ -13,7 +13,7 @@ import java.io.IOException; import java.util.Random; public class FrameLainer extends JFrame { - private DrawingLainer drawingBattleship; + private DrawingLainer drawingLainer; private JComponent pictureBox; public FrameLainer() throws IOException { super("лайнер"); @@ -24,7 +24,7 @@ public class FrameLainer extends JFrame { public void paintComponent(Graphics graphics){ super.paintComponent(graphics); Graphics2D graphics2D = (Graphics2D) graphics; - if (drawingBattleship != null) drawingBattleship.drawTransport(graphics2D); + if (drawingLainer != null) drawingLainer.drawTransport(graphics2D); super.repaint(); } }; @@ -49,7 +49,7 @@ public class FrameLainer extends JFrame { downButton.setActionCommand("down"); downButton.addActionListener(this::buttonMoveClick); - JPanel panelBattleship = new JPanel(new BorderLayout()); + JPanel panelLainer = new JPanel(new BorderLayout()); JPanel createPanel = new JPanel(new BorderLayout()); createPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); JPanel movementPanel = new JPanel(new GridBagLayout()); @@ -75,41 +75,41 @@ public class FrameLainer extends JFrame { setLayout(new BorderLayout()); add(pictureBox); rightPanel.add(movementPanel, BorderLayout.SOUTH); - panelBattleship.add(rightPanel, BorderLayout.EAST); - panelBattleship.add(createPanel, BorderLayout.WEST); - add(panelBattleship,BorderLayout.CENTER); + panelLainer.add(rightPanel, BorderLayout.EAST); + panelLainer.add(createPanel, BorderLayout.WEST); + add(panelLainer,BorderLayout.CENTER); setVisible(true); } private void buttonCreateClick() { Random random = new Random(); - drawingBattleship = new DrawingLainer(); + drawingLainer = new DrawingLainer(); pictureBox.setBounds(0,0,getContentPane().getWidth(),getContentPane().getHeight()); - drawingBattleship.init(random.nextInt(200) + 100, random.nextInt(2000) + 1000, new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)), + drawingLainer.init(random.nextInt(200) + 100, random.nextInt(2000) + 1000, new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)), new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)), random.nextBoolean(), random.nextBoolean(), pictureBox.getWidth(), pictureBox.getHeight(), random.nextInt(4)); - drawingBattleship.setPosition(random.nextInt(90) + 10, random.nextInt(90) + 10); + drawingLainer.setPosition(random.nextInt(90) + 10, random.nextInt(90) + 10); draw(); } private void buttonMoveClick(ActionEvent event) { - if(drawingBattleship == null || drawingBattleship.getEntityLainer() == null) + if(drawingLainer == null || drawingLainer.getEntityLainer() == null) return; switch (event.getActionCommand()) { case "left" : - drawingBattleship.moveTransport(DirectionType.LEFT); + drawingLainer.moveTransport(DirectionType.LEFT); break; case "right" : - drawingBattleship.moveTransport(DirectionType.RIGHT); + drawingLainer.moveTransport(DirectionType.RIGHT); break; case "up" : - drawingBattleship.moveTransport(DirectionType.UP); + drawingLainer.moveTransport(DirectionType.UP); break; case "down" : - drawingBattleship.moveTransport(DirectionType.DOWN); + drawingLainer.moveTransport(DirectionType.DOWN); break; } draw(); } private void draw() { - if (drawingBattleship == null) + if (drawingLainer == null) { return; }