diff --git a/DrawningLocomotive.java b/DrawningLocomotive.java index 5a4e57b..e89236f 100644 --- a/DrawningLocomotive.java +++ b/DrawningLocomotive.java @@ -1,7 +1,7 @@ import java.awt.*; import java.util.Random; -class DrawningLocomotive { +public class DrawningLocomotive { public EntityLocomotive Locomotive; public ExtraWheelsDraw extraWheelsDraw; public IDrawningExtra drawningExtra; diff --git a/FormLocomotive.java b/FormLocomotive.java index 7535926..9adefb3 100644 --- a/FormLocomotive.java +++ b/FormLocomotive.java @@ -5,6 +5,10 @@ import java.util.Random; public class FormLocomotive extends JComponent{ private DrawningLocomotive _locomotive; + private DrawningLocomotive SelectedLocomotive; + public DrawningLocomotive getSelectedLocomotive() { + return SelectedLocomotive; + } public FormLocomotive() { JFrame formFrame = new JFrame("Locomotive"); formFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -62,8 +66,15 @@ public class FormLocomotive extends JComponent{ repaint(); }); + JButton selectLocomotiveButton = new JButton("Select"); + selectLocomotiveButton.addActionListener(e -> { + SelectedLocomotive = _locomotive; + JOptionPane.showMessageDialog(formFrame, "OK"); + }); + statusPanel.add(createButton); statusPanel.add(modifiedButton); + statusPanel.add(selectLocomotiveButton); statusPanel.add(speedLabel); statusPanel.add(weightLabel); statusPanel.add(colorLabel);