From 666de2bf7994228cf819172ebdd163dc74438d0a Mon Sep 17 00:00:00 2001 From: devil_1nc Date: Tue, 8 Nov 2022 14:54:21 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB(?= =?UTF-8?q?=D0=B0)=20=D0=BD=D0=B0=20'FormPlane.java'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FormPlane.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/FormPlane.java b/FormPlane.java index 7bcf85e..1d04e4b 100644 --- a/FormPlane.java +++ b/FormPlane.java @@ -12,7 +12,7 @@ public class FormPlane extends JComponent { JFrame formFrame = new JFrame("Plane"); formFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - formFrame.setSize(920, 560); + formFrame.setSize(840, 560); formFrame.setVisible(true); formFrame.setLocationRelativeTo(null); @@ -46,11 +46,12 @@ public class FormPlane extends JComponent Label colorLabel = new Label("Color:"); JButton createButton = new JButton("Create"); + createButton.addActionListener(e -> { Random rand = new Random(); _plane = new DrawingPlane(); _entity = new EntityPlane(); - _plane.Init(300 + rand.nextInt( 100), 1000 + rand.nextInt(1000), Color.getHSBColor(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256)), _entity); + _plane.Init(rand.nextInt( 400 + rand.nextInt(200)), 1000 + rand.nextInt(1000), Color.getHSBColor(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256)), rand.nextInt(3), _entity); _plane.SetPosition(10 + rand.nextInt(90), 10 + rand.nextInt(90), formFrame.getWidth(), formFrame.getHeight() - 75); speedLabel.setText("Speed: " + _plane.Plane.getSpeed()); weightLabel.setText("Weight: " + (int)_plane.Plane.getWeight()); @@ -84,10 +85,10 @@ public class FormPlane extends JComponent repaint(); }); + statusPanel.add(moveRightButton); + statusPanel.add(moveLeftButton); statusPanel.add(moveUpButton); statusPanel.add(moveDownButton); - statusPanel.add(moveLeftButton); - statusPanel.add(moveRightButton); formFrame.getContentPane().add(this); } @@ -99,7 +100,7 @@ public class FormPlane extends JComponent super.repaint(); } - public static void main(String[] args) throws Exception { + public static void main(String[] args) { new FormPlane(); }