From 2321881dd1fc867e8250e88ec7149d2588dec8ee Mon Sep 17 00:00:00 2001 From: AnnZhimol Date: Sat, 29 Oct 2022 19:59:06 +0400 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=BD=D0=B0=D1=8F=20=D1=83=D1=81=D0=BB=D0=BE=D0=B6=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D0=BD=D0=B0=D1=8F=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80?= =?UTF-8?q?=D0=B0=D1=82=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D0=B0=20=E2=84=963(=D1=82=D0=BE=D1=87=D0=BD=D0=BE)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/CreaterGeneric.java | 1 - src/FormCreater.form | 76 ++++++++++++++++++++--------------------- src/FormCreater.java | 45 ++++++++++++------------ 3 files changed, 62 insertions(+), 60 deletions(-) diff --git a/src/CreaterGeneric.java b/src/CreaterGeneric.java index 34288e1..c1c3f43 100644 --- a/src/CreaterGeneric.java +++ b/src/CreaterGeneric.java @@ -28,7 +28,6 @@ public class CreaterGeneric - + @@ -91,43 +91,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -230,6 +193,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/FormCreater.java b/src/FormCreater.java index 7a3333b..15234ce 100644 --- a/src/FormCreater.java +++ b/src/FormCreater.java @@ -1,5 +1,7 @@ import javax.swing.*; import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.util.Random; public class FormCreater extends JDialog{ @@ -92,29 +94,30 @@ public class FormCreater extends JDialog{ createrGeneric.AddBlock(fblock); }); + BasicRadioButton.addActionListener(e -> { + Color color=JColorChooser.showDialog(this,"Выберите цвет корпуса корабля",Color.WHITE); + if(Integer.parseInt(SpeedTextField.getText())==0 || Integer.parseInt(WeightTextField.getText())==0 || color==null){ + return; + } + createrGeneric.AddWarship(new EntityWarship(Integer.parseInt(SpeedTextField.getText()),Integer.parseInt(WeightTextField.getText()),color)); + }); + + AdvancedRadioButton.addActionListener(e -> { + Color color1=JColorChooser.showDialog(this,"Выберите цвет корпуса корабля",Color.WHITE); + if(Integer.parseInt(SpeedTextField.getText())==0 || Integer.parseInt(WeightTextField.getText())==0 || color1==null){ + return; + } + Color color2=JColorChooser.showDialog(this,"Выберите цвет модификаций корабля",Color.WHITE); + if(color2==null){ + return; + } + createrGeneric.AddWarship(new EntityAdvancedWarship(Integer.parseInt(SpeedTextField.getText()),Integer.parseInt(WeightTextField.getText()), + color1,color2,HelipadCheckBox.isSelected(),AntennaCheckBox.isSelected(),MissileCheckBox.isSelected())); + }); + ShowWarshipButton.addActionListener(e -> { Random rand=new Random(); - if (BasicRadioButton.isSelected()) { - Color color=JColorChooser.showDialog(this,"Выберите цвет корпуса корабля",Color.WHITE); - if(Integer.parseInt(SpeedTextField.getText())==0 || Integer.parseInt(WeightTextField.getText())==0 || color==null){ - return; - } - createrGeneric.AddWarship(new EntityWarship(Integer.parseInt(SpeedTextField.getText()),Integer.parseInt(WeightTextField.getText()),color)); - _warship=createrGeneric.NewWarshipCreating(); - } - if (AdvancedRadioButton.isSelected()){ - Color color1=JColorChooser.showDialog(this,"Выберите цвет корпуса корабля",Color.WHITE); - if(Integer.parseInt(SpeedTextField.getText())==0 || Integer.parseInt(WeightTextField.getText())==0 || color1==null){ - return; - } - Color color2=JColorChooser.showDialog(this,"Выберите цвет модификаций корабля",Color.WHITE); - if(color2==null){ - return; - } - createrGeneric.AddWarship(new EntityAdvancedWarship(Integer.parseInt(SpeedTextField.getText()),Integer.parseInt(WeightTextField.getText()), - color1,color2,HelipadCheckBox.isSelected(),AntennaCheckBox.isSelected(),MissileCheckBox.isSelected())); - _warship=createrGeneric.NewWarshipCreating(); - } + _warship=createrGeneric.NewWarshipCreating(); _warship.SetPosition(rand.nextInt(100),rand.nextInt(100),getWidth(),getHeight()); repaint(); });