Добавлен выбор цвета при создании локомотивов
This commit is contained in:
parent
d91e28ae4a
commit
b28bb84cf8
@ -23,7 +23,10 @@ public class FormLocomotive extends JComponent{
|
||||
JButton createButton = new JButton("Create");
|
||||
createButton.addActionListener(e -> {
|
||||
Random rnd = new Random();
|
||||
_locomotive = new DrawningLocomotive(rnd.nextInt(200) + 100, rnd.nextInt(1000) + 1000, new Color(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)));
|
||||
|
||||
Color colorFirst = JColorChooser.showDialog(null, "Цвет", new Color(rnd.nextInt(256), rnd.nextInt(256),rnd.nextInt(256)));
|
||||
|
||||
_locomotive = new DrawningLocomotive(rnd.nextInt(200) + 100, rnd.nextInt(1000) + 1000, colorFirst);
|
||||
_locomotive.SetPosition(10 + rnd.nextInt(90), 10 + rnd.nextInt(90), 800, 500-75);
|
||||
speedLabel.setText("Speed: " + _locomotive.Locomotive.getSpeed());
|
||||
weightLabel.setText("Weight: " + (int)_locomotive.Locomotive.getWeight());
|
||||
@ -34,9 +37,13 @@ public class FormLocomotive extends JComponent{
|
||||
JButton modifiedButton = new JButton("Modified");
|
||||
modifiedButton.addActionListener(e -> {
|
||||
Random rnd = new Random();
|
||||
|
||||
Color colorFirst = JColorChooser.showDialog(null, "Цвет", new Color(rnd.nextInt(256), rnd.nextInt(256),rnd.nextInt(256)));
|
||||
Color colorSecond = JColorChooser.showDialog(null, "Цвет", new Color(rnd.nextInt(256), rnd.nextInt(256),rnd.nextInt(256)));
|
||||
|
||||
_locomotive = new DrawningWarmlyLocomotive(rnd.nextInt(200) + 100, rnd.nextInt(1000) + 1000,
|
||||
new Color(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)),
|
||||
new Color(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)),
|
||||
colorFirst,
|
||||
colorSecond,
|
||||
rnd.nextBoolean(),
|
||||
rnd.nextBoolean());
|
||||
_locomotive.SetPosition(10 + rnd.nextInt(90), 10 + rnd.nextInt(90), 800, 500 - 75);
|
||||
|
Loading…
Reference in New Issue
Block a user