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