Changed FormArtillery
This commit is contained in:
parent
a5112dcbdd
commit
bea4da357c
@ -53,7 +53,7 @@
|
|||||||
</component>
|
</component>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
<grid id="fa947" binding="pictureBox" layout-manager="GridLayoutManager" row-count="3" column-count="7" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
<grid id="fa947" binding="pictureBox" layout-manager="GridLayoutManager" row-count="3" column-count="8" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
<margin top="0" left="0" bottom="0" right="0"/>
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
@ -61,11 +61,6 @@
|
|||||||
<properties/>
|
<properties/>
|
||||||
<border type="none"/>
|
<border type="none"/>
|
||||||
<children>
|
<children>
|
||||||
<hspacer id="f89d0">
|
|
||||||
<constraints>
|
|
||||||
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
|
||||||
</constraints>
|
|
||||||
</hspacer>
|
|
||||||
<vspacer id="402e3">
|
<vspacer id="402e3">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||||
@ -78,7 +73,7 @@
|
|||||||
</vspacer>
|
</vspacer>
|
||||||
<component id="271ef" class="javax.swing.JButton" binding="buttonUp">
|
<component id="271ef" class="javax.swing.JButton" binding="buttonUp">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="1" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
<grid row="1" column="6" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||||
<minimum-size width="30" height="30"/>
|
<minimum-size width="30" height="30"/>
|
||||||
<preferred-size width="30" height="30"/>
|
<preferred-size width="30" height="30"/>
|
||||||
<maximum-size width="30" height="30"/>
|
<maximum-size width="30" height="30"/>
|
||||||
@ -93,7 +88,7 @@
|
|||||||
</component>
|
</component>
|
||||||
<component id="4b967" class="javax.swing.JButton" binding="buttonDown">
|
<component id="4b967" class="javax.swing.JButton" binding="buttonDown">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="2" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
<grid row="2" column="6" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||||
<minimum-size width="30" height="30"/>
|
<minimum-size width="30" height="30"/>
|
||||||
<preferred-size width="30" height="30"/>
|
<preferred-size width="30" height="30"/>
|
||||||
<maximum-size width="30" height="30"/>
|
<maximum-size width="30" height="30"/>
|
||||||
@ -107,7 +102,7 @@
|
|||||||
</component>
|
</component>
|
||||||
<component id="2e663" class="javax.swing.JButton" binding="buttonLeft">
|
<component id="2e663" class="javax.swing.JButton" binding="buttonLeft">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="2" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
<grid row="2" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||||
<minimum-size width="30" height="30"/>
|
<minimum-size width="30" height="30"/>
|
||||||
<preferred-size width="30" height="30"/>
|
<preferred-size width="30" height="30"/>
|
||||||
<maximum-size width="30" height="30"/>
|
<maximum-size width="30" height="30"/>
|
||||||
@ -122,7 +117,7 @@
|
|||||||
</component>
|
</component>
|
||||||
<component id="c2d76" class="javax.swing.JButton" binding="buttonRight">
|
<component id="c2d76" class="javax.swing.JButton" binding="buttonRight">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="2" column="6" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
<grid row="2" column="7" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||||
<minimum-size width="30" height="30"/>
|
<minimum-size width="30" height="30"/>
|
||||||
<preferred-size width="30" height="30"/>
|
<preferred-size width="30" height="30"/>
|
||||||
<maximum-size width="30" height="30"/>
|
<maximum-size width="30" height="30"/>
|
||||||
@ -153,6 +148,19 @@
|
|||||||
<text value="Модификация"/>
|
<text value="Модификация"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
|
<component id="d034f" class="javax.swing.JButton" binding="buttonSelect">
|
||||||
|
<constraints>
|
||||||
|
<grid row="2" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Выбрать"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<hspacer id="f89d0">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
</hspacer>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
</children>
|
</children>
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.*;
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.ComponentAdapter;
|
|
||||||
import java.awt.event.ComponentEvent;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class FormArtillery extends JFrame {
|
public class FormArtillery extends JFrame {
|
||||||
@ -18,23 +15,21 @@ public class FormArtillery extends JFrame {
|
|||||||
private JButton buttonLeft;
|
private JButton buttonLeft;
|
||||||
private JButton buttonRight;
|
private JButton buttonRight;
|
||||||
private JButton createAdvancedButton;
|
private JButton createAdvancedButton;
|
||||||
|
private JButton buttonSelect;
|
||||||
|
|
||||||
private DrawingArtillery _artillery;
|
private DrawingArtillery _artillery;
|
||||||
|
private DrawingArtillery selectedArtillery;
|
||||||
|
|
||||||
public FormArtillery() {
|
public FormArtillery() {
|
||||||
this.setTitle("Artillery");
|
this.setTitle("Artillery");
|
||||||
this.setContentPane(artilleryPane);
|
this.setContentPane(artilleryPane);
|
||||||
createButton.addActionListener(e -> {
|
createButton.addActionListener(e -> {
|
||||||
Random rnd = new Random();
|
Random rnd = new Random();
|
||||||
_artillery = new DrawingArtillery(
|
Color color = JColorChooser.showDialog(this, "Цвет", new Color(rnd.nextInt(0, 256), rnd.nextInt(0, 256), rnd.nextInt(0, 256)));
|
||||||
rnd.nextInt(100, 300),
|
if (color == null) {
|
||||||
rnd.nextInt(1000, 2000),
|
color = new Color(rnd.nextInt(0, 256), rnd.nextInt(0, 256), rnd.nextInt(0, 256));
|
||||||
new Color(
|
}
|
||||||
rnd.nextInt(0, 256),
|
_artillery = new DrawingArtillery(rnd.nextInt(100, 300), rnd.nextInt(1000, 2000), color, rnd.nextInt(4, 7));
|
||||||
rnd.nextInt(0, 256),
|
|
||||||
rnd.nextInt(0, 256)),
|
|
||||||
rnd.nextInt(4, 7)
|
|
||||||
);
|
|
||||||
_artillery.setPosition(10 + rnd.nextInt(90), 10 + rnd.nextInt(90), pictureBox.getWidth(), pictureBox.getHeight());
|
_artillery.setPosition(10 + rnd.nextInt(90), 10 + rnd.nextInt(90), pictureBox.getWidth(), pictureBox.getHeight());
|
||||||
speedLabel.setText(String.format("Скорость: %s", _artillery.getArtillery().getSpeed()));
|
speedLabel.setText(String.format("Скорость: %s", _artillery.getArtillery().getSpeed()));
|
||||||
weightLabel.setText(String.format("Вес: %s", _artillery.getArtillery().getWeight()));
|
weightLabel.setText(String.format("Вес: %s", _artillery.getArtillery().getWeight()));
|
||||||
@ -66,18 +61,20 @@ public class FormArtillery extends JFrame {
|
|||||||
});
|
});
|
||||||
createAdvancedButton.addActionListener(e -> {
|
createAdvancedButton.addActionListener(e -> {
|
||||||
Random rnd = new Random();
|
Random rnd = new Random();
|
||||||
|
Color color = JColorChooser.showDialog(this, "Основной цвет", Color.white);
|
||||||
|
if (color == null) {
|
||||||
|
color = new Color(rnd.nextInt(0, 256), rnd.nextInt(0, 256), rnd.nextInt(0, 256));
|
||||||
|
}
|
||||||
|
Color dopColor = JColorChooser.showDialog(this, "Дополнительный цвет", Color.white);
|
||||||
|
if (dopColor == null) {
|
||||||
|
dopColor = new Color(rnd.nextInt(0, 256), rnd.nextInt(0, 256), rnd.nextInt(0, 256));
|
||||||
|
}
|
||||||
_artillery = new DrawingAdvancedArtillery(
|
_artillery = new DrawingAdvancedArtillery(
|
||||||
rnd.nextInt(100, 300),
|
rnd.nextInt(100, 300),
|
||||||
rnd.nextInt(1000, 2000),
|
rnd.nextInt(1000, 2000),
|
||||||
new Color(
|
color,
|
||||||
rnd.nextInt(0, 256),
|
|
||||||
rnd.nextInt(0, 256),
|
|
||||||
rnd.nextInt(0, 256)),
|
|
||||||
rnd.nextInt(4, 7),
|
rnd.nextInt(4, 7),
|
||||||
new Color(
|
dopColor,
|
||||||
rnd.nextInt(0, 256),
|
|
||||||
rnd.nextInt(0, 256),
|
|
||||||
rnd.nextInt(0, 256)),
|
|
||||||
rnd.nextBoolean(),
|
rnd.nextBoolean(),
|
||||||
rnd.nextBoolean()
|
rnd.nextBoolean()
|
||||||
);
|
);
|
||||||
@ -87,6 +84,14 @@ public class FormArtillery extends JFrame {
|
|||||||
colorLabel.setText(String.format("Цвет: %x", _artillery.getArtillery().getBodyColor().getRGB()));
|
colorLabel.setText(String.format("Цвет: %x", _artillery.getArtillery().getBodyColor().getRGB()));
|
||||||
repaint();
|
repaint();
|
||||||
});
|
});
|
||||||
|
buttonSelect.addActionListener(e -> {
|
||||||
|
selectedArtillery = _artillery;
|
||||||
|
dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public DrawingArtillery getSelectedArtillery() {
|
||||||
|
return selectedArtillery;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user