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