From 41c6423777fc2d3b3a84abdbab68113963d8ee42 Mon Sep 17 00:00:00 2001 From: ArtemEmelyanov Date: Wed, 14 Dec 2022 13:13:38 +0400 Subject: [PATCH] third complete --- FormParam.java | 85 +++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 46 deletions(-) diff --git a/FormParam.java b/FormParam.java index 2ce4e03..daceb69 100644 --- a/FormParam.java +++ b/FormParam.java @@ -41,17 +41,16 @@ public class FormParam extends JFrame{ gr.setColor(new Color(238, 238, 238)); gr.fillRect(0, 0, pictureBoxPlane.getWidth(), pictureBoxPlane.getHeight()); if (_plane != null) { - _plane.SetPosition(random.nextInt(10, 100), random.nextInt(10, 100), - pictureBoxPlane.getWidth(), pictureBoxPlane.getHeight()); + _plane.SetPosition(random.nextInt(10, 100), random.nextInt(10, 100), pictureBoxPlane.getWidth(), pictureBoxPlane.getHeight()); _plane.DrawTransport(gr); JLabelSpeed.setText("Cкорость: " + _plane.GetPlane().GetSpeed() + " "); JLabelWeight.setText("Вес: " + _plane.GetPlane().GetWeight() + " "); JLabelColor.setText(("Цвет: " + _plane.GetPlane().GetBodyColor() + " ")); - JLabel imageOfShip = new JLabel(); - imageOfShip.setPreferredSize(pictureBoxPlane.getSize()); - imageOfShip.setMinimumSize(new Dimension(1, 1)); - imageOfShip.setIcon(new ImageIcon(bmp)); - pictureBoxPlane.add(imageOfShip,BorderLayout.CENTER); + JLabel imageOfPlane = new JLabel(); + imageOfPlane.setPreferredSize(pictureBoxPlane.getSize()); + imageOfPlane.setMinimumSize(new Dimension(1, 1)); + imageOfPlane.setIcon(new ImageIcon(bmp)); + pictureBoxPlane.add(imageOfPlane,BorderLayout.CENTER); } validate(); } @@ -64,47 +63,41 @@ public class FormParam extends JFrame{ LabelBox.add(JLabelColor); StatusStrip.add(LabelBox); _drawningEntities = new DrawningEntities<>(10,10); - ButtonCreate.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e){ - Random random = new Random(); - Color colorFirst = JColorChooser.showDialog(null, "Цвет", null); - EntityPlane ship=new EntityPlane(random.nextInt(100,300), random.nextInt(1000,2000),colorFirst); - IDrawningIlluminator deck = SetData(); - int DecksCount=random.nextInt(1,4) * 10; - deck.SetIlluminatorCount(DecksCount); - if((_drawningEntities.Insert(ship)!=-1) & (_drawningEntities.Insert(deck)!=-1)) - { - JOptionPane.showMessageDialog(null,"Объект добавлен"); - Draw(_drawningEntities.CreatePlane()); - LabelInfo.setText(_drawningEntities.indx+ " " + _drawningEntities.indy); - } - else - { - JOptionPane.showMessageDialog(null, "Не удалось добавить объект"); - } + ButtonCreate.addActionListener(e -> { + Random random = new Random(); + Color colorFirst = JColorChooser.showDialog(null, "Цвет", null); + EntityPlane _plane = new EntityPlane(random.nextInt(100,300), random.nextInt(1000,2000),colorFirst); + IDrawningIlluminator illum = SetData(); + int IllumCount = random.nextInt(1,4) * 10; + illum.SetIlluminatorCount(IllumCount); + if((_drawningEntities.Insert(_plane)!=-1) & (_drawningEntities.Insert(illum)!=-1)) + { + JOptionPane.showMessageDialog(null,"Объект добавлен"); + Draw(_drawningEntities.CreatePlane()); + LabelInfo.setText(_drawningEntities.indx+ " " + _drawningEntities.indy); + } + else + { + JOptionPane.showMessageDialog(null, "Не удалось добавить объект"); } }); - ButtonCreateModif.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - Random random = new Random(); - Color colorFirst = JColorChooser.showDialog(null, "Цвет", null); - Color colorSecond = JColorChooser.showDialog(null, "Цвет", null); - EntityAirbus _ship=new EntityAirbus(random.nextInt(100, 300), random.nextInt(1000, 2000), colorFirst, colorSecond, random.nextBoolean(), random.nextBoolean(), random.nextBoolean()); - IDrawningIlluminator deck = SetData(); - int DecksCount=random.nextInt(1,4) * 10; - deck.SetIlluminatorCount(DecksCount); - if((_drawningEntities.Insert(_ship)!=-1) & (_drawningEntities.Insert(deck)!=-1)) - { - JOptionPane.showMessageDialog(null,"Объект добавлен"); - Draw(_drawningEntities.CreatePlane()); - LabelInfo.setText(_drawningEntities.indx+ " " + _drawningEntities.indy); - } - else - { - JOptionPane.showMessageDialog(null, "Не удалось добавить объект"); - } + ButtonCreateModif.addActionListener(e -> { + Random random = new Random(); + Color colorFirst = JColorChooser.showDialog(null, "Цвет", null); + Color colorSecond = JColorChooser.showDialog(null, "Цвет", null); + EntityAirbus _plane = new EntityAirbus(random.nextInt(100, 300), random.nextInt(1000, 2000), colorFirst, colorSecond, random.nextBoolean(), random.nextBoolean(), random.nextBoolean()); + IDrawningIlluminator illum = SetData(); + int IllumCount = random.nextInt(1,4) * 10; + illum.SetIlluminatorCount(IllumCount); + if((_drawningEntities.Insert(_plane)!=-1) & (_drawningEntities.Insert(illum)!=-1)) + { + JOptionPane.showMessageDialog(null,"Объект добавлен"); + Draw(_drawningEntities.CreatePlane()); + LabelInfo.setText(_drawningEntities.indx+ " " + _drawningEntities.indy); + } + else + { + JOptionPane.showMessageDialog(null, "Не удалось добавить объект"); } }); }