From a2e55353863c0745647a3cd5f9987f7a8fccbfed Mon Sep 17 00:00:00 2001 From: AnnZhimol Date: Wed, 19 Oct 2022 09:53:20 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A2=D1=80=D0=B5=D1=82=D0=B8=D0=B9=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BC=D0=BC=D0=B8=D1=82.=20=D0=A3=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=20jcolorchooser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/DrawingField.java | 15 +++------------ src/DrawingMap.java | 12 +++--------- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/DrawingField.java b/src/DrawingField.java index b46e965..4569581 100644 --- a/src/DrawingField.java +++ b/src/DrawingField.java @@ -31,22 +31,13 @@ public class DrawingField extends JPanel{ } public void CreateButtonAction(){ Random rand=new Random(); - Color color1 = JColorChooser.showDialog(Field, "Выберите цвет тела корабля", null); - if(color1==null) - color1=new Color(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256)); - _warship=new DrawingWarship(rand.nextInt(50)+10,rand.nextInt(3000)+20000,color1,rand.nextInt(3)); + _warship=new DrawingWarship(rand.nextInt(50)+10,rand.nextInt(3000)+20000,new Color(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256)),rand.nextInt(3)); SetData(); } public void CreateModifButtonAction(){ Random rand=new Random(); - Color color1=JColorChooser.showDialog(Field, "Выберите цвет тела корабля",null); - Color color2=JColorChooser.showDialog(Field, "Выборите цвет модификаций корабля",null); - if(color1==null) - color1=new Color(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256)); - if (color2==null) - color2=new Color(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256)); - _warship = new DrawingAdvancedWarship(rand.nextInt(50) + 10, rand.nextInt(3000) + 20000, color1, - color2, rand.nextBoolean(), rand.nextBoolean(), rand.nextBoolean(),rand.nextInt(3)); + _warship = new DrawingAdvancedWarship(rand.nextInt(50) + 10, rand.nextInt(3000) + 20000, new Color(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256)), + new Color(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256)), rand.nextBoolean(), rand.nextBoolean(), rand.nextBoolean(),rand.nextInt(3)); SetData(); } public void ResizeField(){ diff --git a/src/DrawingMap.java b/src/DrawingMap.java index 36ae792..150c1c9 100644 --- a/src/DrawingMap.java +++ b/src/DrawingMap.java @@ -29,20 +29,14 @@ public class DrawingMap extends JPanel { } public void CreateButtonAction(){ Random rand=new Random(); - Color color1 = JColorChooser.showDialog(Map, "Выберите цвет тела корабля", null); - if(color1==null) - color1=new Color(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256)); + Color color1=new Color(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256)); DrawingWarship warship=new DrawingWarship(rand.nextInt(50)+10,rand.nextInt(3000)+20000,color1,rand.nextInt(3)); SetData(warship); } public void CreateModifButtonAction(){ Random rand=new Random(); - Color color1=JColorChooser.showDialog(Map, "Выберите цвет тела корабля",null); - Color color2=JColorChooser.showDialog(Map, "Выборите цвет модификаций корабля",null); - if(color1==null) - color1=new Color(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256)); - if (color2==null) - color2=new Color(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256)); + Color color1=new Color(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256)); + Color color2=new Color(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256)); DrawingWarship warship = new DrawingAdvancedWarship(rand.nextInt(50) + 10, rand.nextInt(3000) + 20000, color1, color2, rand.nextBoolean(), rand.nextBoolean(), rand.nextBoolean(),rand.nextInt(3)); SetData(warship);