Borschevskaya A.A. Lab Work 2 Hard #2
@ -22,7 +22,7 @@
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="7c72e" layout-manager="GridLayoutManager" row-count="2" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="7c72e" layout-manager="GridLayoutManager" row-count="2" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="true"/>
|
||||
@ -40,7 +40,7 @@
|
||||
</component>
|
||||
<component id="f4d6e" class="javax.swing.JButton" binding="buttonRight">
|
||||
<constraints>
|
||||
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="1" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<icon value="Right.png"/>
|
||||
@ -49,7 +49,7 @@
|
||||
</component>
|
||||
<component id="12974" class="javax.swing.JButton" binding="buttonUp">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<enabled value="true"/>
|
||||
@ -60,7 +60,7 @@
|
||||
</component>
|
||||
<component id="da478" class="javax.swing.JButton" binding="buttonDown">
|
||||
<constraints>
|
||||
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<icon value="Down.png"/>
|
||||
@ -69,7 +69,7 @@
|
||||
</component>
|
||||
<component id="43d8e" class="javax.swing.JButton" binding="buttonLeft">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<icon value="Left.png"/>
|
||||
@ -77,6 +77,14 @@
|
||||
<visible value="true"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="64b34" class="javax.swing.JButton" binding="buttonCreate_Modif">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Модификация"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<component id="2cd31" class="javax.swing.JLabel" binding="labelSpeed">
|
||||
|
@ -17,6 +17,7 @@ public class FormArmoredCar extends JFrame{
|
||||
private JLabel labelSpeed;
|
||||
private JLabel labelWeight;
|
||||
private JLabel labelColor;
|
||||
private JButton buttonCreate_Modif;
|
||||
|
||||
private DrawingArmoredCar armoredCar;
|
||||
|
||||
@ -45,12 +46,7 @@ public class FormArmoredCar extends JFrame{
|
||||
armoredCar = new DrawingArmoredCar(rnd.nextInt(100,300), rnd.nextInt(1000, 2000),
|
||||
new Color(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)));
|
||||
|
||||
armoredCar.SetPosition(rnd.nextInt(10, 100), rnd.nextInt(10, 100),
|
||||
drawPanel.getWidth(), drawPanel.getHeight());
|
||||
|
||||
labelSpeed.setText("Скорость: " + armoredCar.getArmoredCar().getSpeed());
|
||||
labelWeight.setText("Вес: " + armoredCar.getArmoredCar().getWeight());
|
||||
labelColor.setText("Цвет: " + armoredCar.getArmoredCar().getBodyColor().getRGB());
|
||||
setData();
|
||||
}
|
||||
});
|
||||
|
||||
@ -93,6 +89,20 @@ public class FormArmoredCar extends JFrame{
|
||||
|
||||
setContentPane(mainPanel);
|
||||
setVisible(true);
|
||||
buttonCreate_Modif.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Random rnd = new Random();
|
||||
armoredCar = new DrawingTank(rnd.nextInt(100, 300), rnd.nextInt(1000,
|
||||
2000),
|
||||
new Color(rnd.nextInt(0, 256), rnd.nextInt(0, 256), rnd.nextInt(0,
|
||||
256)),
|
||||
new Color(rnd.nextInt(0, 256), rnd.nextInt(0, 256), rnd.nextInt(0,
|
||||
256)),
|
||||
1==rnd.nextInt(0, 2), 1==rnd.nextInt(0, 2));
|
||||
setData();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void createUIComponents() {
|
||||
@ -108,4 +118,13 @@ public class FormArmoredCar extends JFrame{
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void setData()
|
||||
{
|
||||
Random rnd = new Random();
|
||||
armoredCar.SetPosition(rnd.nextInt(10, 100), rnd.nextInt(10, 100), drawPanel.getWidth(), drawPanel.getHeight());
|
||||
labelSpeed.setText("Скорость: " + armoredCar.getArmoredCar().getSpeed());
|
||||
labelWeight.setText("Вес: " + armoredCar.getArmoredCar().getWeight());
|
||||
labelColor.setText("Цвет: " + armoredCar.getArmoredCar().getBodyColor().getRGB());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user