Изменил(а) на 'FormPlane.java'
This commit is contained in:
parent
91db5cf763
commit
666de2bf79
@ -12,7 +12,7 @@ public class FormPlane extends JComponent
|
|||||||
{
|
{
|
||||||
JFrame formFrame = new JFrame("Plane");
|
JFrame formFrame = new JFrame("Plane");
|
||||||
formFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
formFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
formFrame.setSize(920, 560);
|
formFrame.setSize(840, 560);
|
||||||
formFrame.setVisible(true);
|
formFrame.setVisible(true);
|
||||||
formFrame.setLocationRelativeTo(null);
|
formFrame.setLocationRelativeTo(null);
|
||||||
|
|
||||||
@ -46,11 +46,12 @@ public class FormPlane extends JComponent
|
|||||||
Label colorLabel = new Label("Color:");
|
Label colorLabel = new Label("Color:");
|
||||||
|
|
||||||
JButton createButton = new JButton("Create");
|
JButton createButton = new JButton("Create");
|
||||||
|
|
||||||
createButton.addActionListener(e -> {
|
createButton.addActionListener(e -> {
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
_plane = new DrawingPlane();
|
_plane = new DrawingPlane();
|
||||||
_entity = new EntityPlane();
|
_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);
|
_plane.SetPosition(10 + rand.nextInt(90), 10 + rand.nextInt(90), formFrame.getWidth(), formFrame.getHeight() - 75);
|
||||||
speedLabel.setText("Speed: " + _plane.Plane.getSpeed());
|
speedLabel.setText("Speed: " + _plane.Plane.getSpeed());
|
||||||
weightLabel.setText("Weight: " + (int)_plane.Plane.getWeight());
|
weightLabel.setText("Weight: " + (int)_plane.Plane.getWeight());
|
||||||
@ -84,10 +85,10 @@ public class FormPlane extends JComponent
|
|||||||
repaint();
|
repaint();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
statusPanel.add(moveRightButton);
|
||||||
|
statusPanel.add(moveLeftButton);
|
||||||
statusPanel.add(moveUpButton);
|
statusPanel.add(moveUpButton);
|
||||||
statusPanel.add(moveDownButton);
|
statusPanel.add(moveDownButton);
|
||||||
statusPanel.add(moveLeftButton);
|
|
||||||
statusPanel.add(moveRightButton);
|
|
||||||
|
|
||||||
formFrame.getContentPane().add(this);
|
formFrame.getContentPane().add(this);
|
||||||
}
|
}
|
||||||
@ -99,7 +100,7 @@ public class FormPlane extends JComponent
|
|||||||
super.repaint();
|
super.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) {
|
||||||
new FormPlane();
|
new FormPlane();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user