Form1
This commit is contained in:
parent
c1a5d23a36
commit
8562c126a2
@ -7,6 +7,8 @@ import javax.swing.Timer;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class FormTrain{
|
||||
public DrawingTrain SelectedTrain;
|
||||
public boolean DialogResult = false;
|
||||
private DrawingTrain _drawingTrain;
|
||||
private AbstractStrategy abstractStrategy;
|
||||
Canvas canv;
|
||||
@ -18,11 +20,14 @@ public class FormTrain{
|
||||
}
|
||||
|
||||
public FormTrain(){
|
||||
SelectedTrain = null;
|
||||
JFrame w=new JFrame ("Loco");
|
||||
JButton buttonCreate = new JButton("create");
|
||||
JButton buttonCreateLocomotive = new JButton("createLocomotive");
|
||||
JButton buttonCreateLocomotive = new JButton("create locomotive");
|
||||
JButton buttonStrategysStep = new JButton("strategys step");
|
||||
JComboBox comboBoxStrategy = new JComboBox(
|
||||
JButton buttonSelectTrain = new JButton("select train");
|
||||
|
||||
JComboBox<String> comboBoxStrategy = new JComboBox<String>(
|
||||
new String[]{
|
||||
"к центру",
|
||||
"к краю",
|
||||
@ -51,6 +56,15 @@ public class FormTrain{
|
||||
right.setContentAreaFilled(false);
|
||||
right.setName("right");
|
||||
right.setIcon(new ImageIcon("D:\\Coffee\\PIbd-21_Kouvshinoff_T._A._WarmlyLocomotive._Harder\\laba1Loco\\images\\arowR340x259.png"));
|
||||
buttonSelectTrain.addActionListener(
|
||||
new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e){
|
||||
SelectedTrain = _drawingTrain;
|
||||
DialogResult = true;
|
||||
w.dispose();
|
||||
}
|
||||
}
|
||||
);
|
||||
buttonStrategysStep.addActionListener(
|
||||
new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e){
|
||||
@ -100,12 +114,26 @@ public class FormTrain{
|
||||
public void actionPerformed(ActionEvent e){
|
||||
System.out.println(e.getActionCommand());
|
||||
Random random = new Random();
|
||||
Color color = new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256));
|
||||
// Вызываем диалоговое окно выбора цвета
|
||||
Color selectedColor = JColorChooser.showDialog(w, "Выберите цвет", Color.WHITE);
|
||||
if (selectedColor != null)
|
||||
{
|
||||
color = selectedColor;
|
||||
}
|
||||
Color color2 = new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256));
|
||||
// Вызываем диалоговое окно выбора цвета
|
||||
selectedColor = JColorChooser.showDialog(w, "Выберите цвет", Color.WHITE);
|
||||
if (selectedColor != null)
|
||||
{
|
||||
color2 = selectedColor;
|
||||
}
|
||||
_drawingTrain = new DrawingLoco(
|
||||
random.nextInt(100, 300),
|
||||
random.nextInt(1000, 3000),
|
||||
new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)),
|
||||
color,
|
||||
random.nextInt(2, 5),
|
||||
new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)),
|
||||
color2,
|
||||
random.nextInt(0, 2) == 1,
|
||||
random.nextInt(0, 2) == 1,
|
||||
random.nextInt(0, 2) == 1,
|
||||
@ -122,10 +150,17 @@ public class FormTrain{
|
||||
public void actionPerformed(ActionEvent e){
|
||||
System.out.println(e.getActionCommand());
|
||||
Random random = new Random();
|
||||
Color color = new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256));
|
||||
// Вызываем диалоговое окно выбора цвета
|
||||
Color selectedColor = JColorChooser.showDialog(w, "Выберите цвет", Color.WHITE);
|
||||
if (selectedColor != null)
|
||||
{
|
||||
color = selectedColor;
|
||||
}
|
||||
_drawingTrain = new DrawingTrain(
|
||||
random.nextInt(100, 300),
|
||||
random.nextInt(1000, 3000),
|
||||
new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)),
|
||||
color,
|
||||
random.nextInt(2, 5),
|
||||
pictureBoxWidth,
|
||||
pictureBoxHeight);
|
||||
@ -177,6 +212,8 @@ public class FormTrain{
|
||||
right.setBounds(940, 520, 40, 40);
|
||||
comboBoxStrategy.setBounds(pictureBoxWidth - 150, 20, 150, 20);
|
||||
buttonStrategysStep.setBounds(pictureBoxWidth - 150, 45, 150, 20);
|
||||
buttonSelectTrain.setBounds(pictureBoxWidth/2, 540, 150, 20);
|
||||
w.add(buttonSelectTrain);
|
||||
w.add(canv);
|
||||
w.add(buttonCreate);
|
||||
w.add(buttonCreateLocomotive);
|
||||
@ -186,6 +223,7 @@ public class FormTrain{
|
||||
w.add(right);
|
||||
w.add(comboBoxStrategy);
|
||||
w.add(buttonStrategysStep);
|
||||
w.setVisible(true);
|
||||
}
|
||||
}
|
||||
class Canvas extends JComponent{
|
||||
|
Loading…
Reference in New Issue
Block a user