Initial Commit. LabWork02 started

This commit is contained in:
Данила Мочалов 2022-10-08 16:09:23 +04:00
parent ac9d6db704
commit 8e2dd53ece

View File

@ -55,25 +55,25 @@ public class FormLocomotive extends JComponent{
statusPanel.add(weightLabel); statusPanel.add(weightLabel);
statusPanel.add(colorLabel); statusPanel.add(colorLabel);
JButton moveDownButton = new JButton("Down"); JButton moveDownButton = new JButton("D");
moveDownButton.addActionListener(e -> { moveDownButton.addActionListener(e -> {
if (_locomotive != null) _locomotive.MoveTransport(Direction.Down); if (_locomotive != null) _locomotive.MoveTransport(Direction.Down);
repaint(); repaint();
}); });
JButton moveUpButton = new JButton("Up"); JButton moveUpButton = new JButton("U");
moveUpButton.addActionListener(e -> { moveUpButton.addActionListener(e -> {
if (_locomotive != null) _locomotive.MoveTransport(Direction.Up); if (_locomotive != null) _locomotive.MoveTransport(Direction.Up);
repaint(); repaint();
}); });
JButton moveLeftButton = new JButton("Left"); JButton moveLeftButton = new JButton("L");
moveLeftButton.addActionListener(e -> { moveLeftButton.addActionListener(e -> {
if (_locomotive != null) _locomotive.MoveTransport(Direction.Left); if (_locomotive != null) _locomotive.MoveTransport(Direction.Left);
repaint(); repaint();
}); });
JButton moveRightButton = new JButton("Right"); JButton moveRightButton = new JButton("R");
moveRightButton.addActionListener(e -> { moveRightButton.addActionListener(e -> {
if (_locomotive != null) _locomotive.MoveTransport(Direction.Right); if (_locomotive != null) _locomotive.MoveTransport(Direction.Right);
repaint(); repaint();
@ -96,6 +96,6 @@ public class FormLocomotive extends JComponent{
} }
public static void main(String[] args) { public static void main(String[] args) {
FormLocomotive formLocomotive = new FormLocomotive(); new FormLocomotive();
} }
} }