Готовая лабораторная работа 3

This commit is contained in:
Никита Белянин 2023-11-12 15:31:20 +04:00
parent 585424fb62
commit 17d9a3f417

View File

@ -49,23 +49,23 @@ public class FormTank {
});
JButton up = new JButton();
up.setName("up");
ImageIcon iconUp = new ImageIcon("Tank//Resources//KeyUp.png");
ImageIcon iconUp = new ImageIcon("Resources//KeyUp.png");
up.setIcon(iconUp);
JButton down = new JButton();
down.setName("down");
ImageIcon iconDown = new ImageIcon("Tank//Resources//KeyDown.png");
ImageIcon iconDown = new ImageIcon("Resources//KeyDown.png");
down.setIcon(iconDown);
JButton left = new JButton();
left.setName("left");
ImageIcon iconLeft = new ImageIcon("Tank//Resources//KeyLeft.png");
ImageIcon iconLeft = new ImageIcon("Resources//KeyLeft.png");
left.setIcon(iconLeft);
JButton right = new JButton();
right.setName("right");
ImageIcon iconRight = new ImageIcon("Tank//Resources//KeyRight.png");
ImageIcon iconRight = new ImageIcon("Resources//KeyRight.png");
right.setIcon(iconRight);
buttonStrategysStep.addActionListener(
@ -86,13 +86,11 @@ public class FormTank {
abstractStrategy = null;
break;
}
;
if (abstractStrategy == null) {
return;
}
abstractStrategy.SetData(new
DrawingObjectTank(_drawingTank), pictureBoxWidth,
pictureBoxHeight);
abstractStrategy.SetData(new DrawingObjectTank(_drawingTank), pictureBoxWidth, pictureBoxHeight);
comboBoxStrategy.setEnabled(false);
}
if (abstractStrategy == null) {
@ -110,7 +108,6 @@ public class FormTank {
buttonCreateTank.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println(e.getActionCommand());
Random random = new Random();
Color color = new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256));
// Вызываем диалоговое окно выбора цвета
@ -118,18 +115,18 @@ public class FormTank {
if (selectedColor != null) {
color = selectedColor;
}
Color color2 = new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256));
Color coloradditional = new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256));
// Вызываем диалоговое окно выбора цвета
selectedColor = JColorChooser.showDialog(Frame, "Выберите цвет", Color.WHITE);
if (selectedColor != null) {
color2 = selectedColor;
coloradditional = selectedColor;
}
_drawingTank = new DrawingTank(
random.nextInt(100, 300),
random.nextInt(1000, 3000),
color,
random.nextInt(2, 5),
color2,
coloradditional,
true,
true,
true,
@ -145,7 +142,6 @@ public class FormTank {
buttonCreate.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println(e.getActionCommand());
Random random = new Random();
Color color = new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256));
// Вызываем диалоговое окно выбора цвета
@ -170,7 +166,6 @@ public class FormTank {
ActionListener actioListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println(((JButton) (e.getSource())).getName());
if (_drawingTank == null) {
return;
}