Changed FormArtillery
This commit is contained in:
parent
a5112dcbdd
commit
bea4da357c
@ -53,7 +53,7 @@
|
||||
</component>
|
||||
</children>
|
||||
</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"/>
|
||||
<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"/>
|
||||
@ -61,11 +61,6 @@
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<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">
|
||||
<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"/>
|
||||
@ -78,7 +73,7 @@
|
||||
</vspacer>
|
||||
<component id="271ef" class="javax.swing.JButton" binding="buttonUp">
|
||||
<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"/>
|
||||
<preferred-size width="30" height="30"/>
|
||||
<maximum-size width="30" height="30"/>
|
||||
@ -93,7 +88,7 @@
|
||||
</component>
|
||||
<component id="4b967" class="javax.swing.JButton" binding="buttonDown">
|
||||
<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"/>
|
||||
<preferred-size width="30" height="30"/>
|
||||
<maximum-size width="30" height="30"/>
|
||||
@ -107,7 +102,7 @@
|
||||
</component>
|
||||
<component id="2e663" class="javax.swing.JButton" binding="buttonLeft">
|
||||
<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"/>
|
||||
<preferred-size width="30" height="30"/>
|
||||
<maximum-size width="30" height="30"/>
|
||||
@ -122,7 +117,7 @@
|
||||
</component>
|
||||
<component id="c2d76" class="javax.swing.JButton" binding="buttonRight">
|
||||
<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"/>
|
||||
<preferred-size width="30" height="30"/>
|
||||
<maximum-size width="30" height="30"/>
|
||||
@ -153,6 +148,19 @@
|
||||
<text value="Модификация"/>
|
||||
</properties>
|
||||
</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>
|
||||
</grid>
|
||||
</children>
|
||||
|
@ -1,9 +1,6 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.*;
|
||||
import java.util.Random;
|
||||
|
||||
public class FormArtillery extends JFrame {
|
||||
@ -18,23 +15,21 @@ public class FormArtillery extends JFrame {
|
||||
private JButton buttonLeft;
|
||||
private JButton buttonRight;
|
||||
private JButton createAdvancedButton;
|
||||
private JButton buttonSelect;
|
||||
|
||||
private DrawingArtillery _artillery;
|
||||
private DrawingArtillery selectedArtillery;
|
||||
|
||||
public FormArtillery() {
|
||||
this.setTitle("Artillery");
|
||||
this.setContentPane(artilleryPane);
|
||||
createButton.addActionListener(e -> {
|
||||
Random rnd = new Random();
|
||||
_artillery = new DrawingArtillery(
|
||||
rnd.nextInt(100, 300),
|
||||
rnd.nextInt(1000, 2000),
|
||||
new Color(
|
||||
rnd.nextInt(0, 256),
|
||||
rnd.nextInt(0, 256),
|
||||
rnd.nextInt(0, 256)),
|
||||
rnd.nextInt(4, 7)
|
||||
);
|
||||
Color color = JColorChooser.showDialog(this, "Цвет", new Color(rnd.nextInt(0, 256), rnd.nextInt(0, 256), rnd.nextInt(0, 256)));
|
||||
if (color == null) {
|
||||
color = new Color(rnd.nextInt(0, 256), rnd.nextInt(0, 256), rnd.nextInt(0, 256));
|
||||
}
|
||||
_artillery = new DrawingArtillery(rnd.nextInt(100, 300), rnd.nextInt(1000, 2000), color, rnd.nextInt(4, 7));
|
||||
_artillery.setPosition(10 + rnd.nextInt(90), 10 + rnd.nextInt(90), pictureBox.getWidth(), pictureBox.getHeight());
|
||||
speedLabel.setText(String.format("Скорость: %s", _artillery.getArtillery().getSpeed()));
|
||||
weightLabel.setText(String.format("Вес: %s", _artillery.getArtillery().getWeight()));
|
||||
@ -66,18 +61,20 @@ public class FormArtillery extends JFrame {
|
||||
});
|
||||
createAdvancedButton.addActionListener(e -> {
|
||||
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(
|
||||
rnd.nextInt(100, 300),
|
||||
rnd.nextInt(1000, 2000),
|
||||
new Color(
|
||||
rnd.nextInt(0, 256),
|
||||
rnd.nextInt(0, 256),
|
||||
rnd.nextInt(0, 256)),
|
||||
color,
|
||||
rnd.nextInt(4, 7),
|
||||
new Color(
|
||||
rnd.nextInt(0, 256),
|
||||
rnd.nextInt(0, 256),
|
||||
rnd.nextInt(0, 256)),
|
||||
dopColor,
|
||||
rnd.nextBoolean(),
|
||||
rnd.nextBoolean()
|
||||
);
|
||||
@ -87,6 +84,14 @@ public class FormArtillery extends JFrame {
|
||||
colorLabel.setText(String.format("Цвет: %x", _artillery.getArtillery().getBodyColor().getRGB()));
|
||||
repaint();
|
||||
});
|
||||
buttonSelect.addActionListener(e -> {
|
||||
selectedArtillery = _artillery;
|
||||
dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
|
||||
});
|
||||
}
|
||||
|
||||
public DrawingArtillery getSelectedArtillery() {
|
||||
return selectedArtillery;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user