Изменил(а) на 'FormPlane.java'

This commit is contained in:
devil_1nc 2022-11-08 14:54:21 +04:00
parent 91db5cf763
commit 666de2bf79

View File

@ -12,7 +12,7 @@ public class FormPlane extends JComponent
{
JFrame formFrame = new JFrame("Plane");
formFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
formFrame.setSize(920, 560);
formFrame.setSize(840, 560);
formFrame.setVisible(true);
formFrame.setLocationRelativeTo(null);
@ -46,11 +46,12 @@ public class FormPlane extends JComponent
Label colorLabel = new Label("Color:");
JButton createButton = new JButton("Create");
createButton.addActionListener(e -> {
Random rand = new Random();
_plane = new DrawingPlane();
_entity = new EntityPlane();
_plane.Init(300 + rand.nextInt( 100), 1000 + rand.nextInt(1000), Color.getHSBColor(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256)), _entity);
_plane.Init(rand.nextInt( 400 + rand.nextInt(200)), 1000 + rand.nextInt(1000), Color.getHSBColor(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256)), rand.nextInt(3), _entity);
_plane.SetPosition(10 + rand.nextInt(90), 10 + rand.nextInt(90), formFrame.getWidth(), formFrame.getHeight() - 75);
speedLabel.setText("Speed: " + _plane.Plane.getSpeed());
weightLabel.setText("Weight: " + (int)_plane.Plane.getWeight());
@ -84,10 +85,10 @@ public class FormPlane extends JComponent
repaint();
});
statusPanel.add(moveRightButton);
statusPanel.add(moveLeftButton);
statusPanel.add(moveUpButton);
statusPanel.add(moveDownButton);
statusPanel.add(moveLeftButton);
statusPanel.add(moveRightButton);
formFrame.getContentPane().add(this);
}
@ -99,7 +100,7 @@ public class FormPlane extends JComponent
super.repaint();
}
public static void main(String[] args) throws Exception {
public static void main(String[] args) {
new FormPlane();
}