From 896285b4c5ce1a5037b28bb290fbcf67dfdb569b Mon Sep 17 00:00:00 2001 From: Danila_Mochalov Date: Fri, 21 Oct 2022 16:38:26 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9A=D0=BD=D0=BE=D0=BF=D0=BA=D0=B0=20Select?= =?UTF-8?q?=20=D0=B8=20=D1=81=D0=B2=D0=BE=D0=B9=D1=81=D1=82=D0=B2=D0=BE=20?= =?UTF-8?q?SelectedLocomotive=20=D0=B2=20FormLocomotive?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrawningLocomotive.java | 2 +- FormLocomotive.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) 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);