Кнопка Select и свойство SelectedLocomotive в FormLocomotive
This commit is contained in:
parent
95edf9e7d2
commit
896285b4c5
@ -1,7 +1,7 @@
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
class DrawningLocomotive {
|
public class DrawningLocomotive {
|
||||||
public EntityLocomotive Locomotive;
|
public EntityLocomotive Locomotive;
|
||||||
public ExtraWheelsDraw extraWheelsDraw;
|
public ExtraWheelsDraw extraWheelsDraw;
|
||||||
public IDrawningExtra drawningExtra;
|
public IDrawningExtra drawningExtra;
|
||||||
|
@ -5,6 +5,10 @@ import java.util.Random;
|
|||||||
|
|
||||||
public class FormLocomotive extends JComponent{
|
public class FormLocomotive extends JComponent{
|
||||||
private DrawningLocomotive _locomotive;
|
private DrawningLocomotive _locomotive;
|
||||||
|
private DrawningLocomotive SelectedLocomotive;
|
||||||
|
public DrawningLocomotive getSelectedLocomotive() {
|
||||||
|
return SelectedLocomotive;
|
||||||
|
}
|
||||||
public FormLocomotive() {
|
public FormLocomotive() {
|
||||||
JFrame formFrame = new JFrame("Locomotive");
|
JFrame formFrame = new JFrame("Locomotive");
|
||||||
formFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
formFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
@ -62,8 +66,15 @@ public class FormLocomotive extends JComponent{
|
|||||||
repaint();
|
repaint();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
JButton selectLocomotiveButton = new JButton("Select");
|
||||||
|
selectLocomotiveButton.addActionListener(e -> {
|
||||||
|
SelectedLocomotive = _locomotive;
|
||||||
|
JOptionPane.showMessageDialog(formFrame, "OK");
|
||||||
|
});
|
||||||
|
|
||||||
statusPanel.add(createButton);
|
statusPanel.add(createButton);
|
||||||
statusPanel.add(modifiedButton);
|
statusPanel.add(modifiedButton);
|
||||||
|
statusPanel.add(selectLocomotiveButton);
|
||||||
statusPanel.add(speedLabel);
|
statusPanel.add(speedLabel);
|
||||||
statusPanel.add(weightLabel);
|
statusPanel.add(weightLabel);
|
||||||
statusPanel.add(colorLabel);
|
statusPanel.add(colorLabel);
|
||||||
|
Loading…
Reference in New Issue
Block a user