тепловозы появляются
This commit is contained in:
parent
490b9151ce
commit
b672e4c67b
@ -1,5 +1,6 @@
|
||||
import java.awt.*;
|
||||
|
||||
|
||||
public class DrawingWarmlyLocomotive {
|
||||
|
||||
private EntityWarmlyLocomotive EntityWarmlyLocomotive;
|
||||
|
@ -1,6 +1,13 @@
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class FormWarmlyLocomotive extends JFrame {
|
||||
DrawingWarmlyLocomotive _drawningWarmlyLocomotive;
|
||||
JPanel pictureBox;
|
||||
|
||||
public void Initialize(){
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
@ -10,14 +17,25 @@ public class FormWarmlyLocomotive extends JFrame {
|
||||
setResizable(false);
|
||||
|
||||
//pictireBox
|
||||
JPanel pictureBox = new JPanel();
|
||||
pictureBox = new JPanel();
|
||||
pictureBox.setSize(getWidth(), getHeight());
|
||||
pictureBox.setLayout(null);
|
||||
|
||||
//createButton
|
||||
JButton createButton = new JButton("Создать");
|
||||
createButton.setBounds(10, 420, 90, 30);
|
||||
createButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
createButton_Click();
|
||||
//repaint();
|
||||
System.out.println("helpmepls");
|
||||
}
|
||||
});
|
||||
//createButton.setBounds(10, 420, 90, 30);
|
||||
createButton.setSize(90, 30);
|
||||
createButton.setLocation(10, 420);
|
||||
pictureBox.add(createButton);
|
||||
|
||||
|
||||
//upButton
|
||||
JButton upButton = new JButton();
|
||||
@ -52,6 +70,38 @@ public class FormWarmlyLocomotive extends JFrame {
|
||||
pictureBox.add(leftButton);
|
||||
repaint();
|
||||
add(pictureBox);
|
||||
|
||||
Graphics g = pictureBox.getGraphics();
|
||||
g.setColor(Color.BLACK);
|
||||
g.fillRect(100, 100, 100, 100);
|
||||
repaint();
|
||||
|
||||
|
||||
}
|
||||
|
||||
// private void Draw()
|
||||
// {
|
||||
// if (_drawningWarmlyLocomotive.equals(null))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// BufferedImage bmp = new BufferedImage(getWidth(), getHeight(), 1);
|
||||
// Graphics gr = bmp.getGraphics();
|
||||
// _drawningWarmlyLocomotive.DrawTransport(gr);
|
||||
// repaint();
|
||||
// }
|
||||
|
||||
private void createButton_Click(){
|
||||
Random random = new Random();
|
||||
_drawningWarmlyLocomotive = new DrawingWarmlyLocomotive();
|
||||
_drawningWarmlyLocomotive.Init(
|
||||
random.nextInt(200) + 100,
|
||||
random.nextInt(2000) + 1000,
|
||||
new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)),
|
||||
new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)),
|
||||
random.nextInt(2) != 0, random.nextInt(2) != 0);
|
||||
_drawningWarmlyLocomotive.SetPictureSize(getWidth(), getHeight());
|
||||
_drawningWarmlyLocomotive.SetPosition(random.nextInt(90) + 10, random.nextInt(90) + 10);
|
||||
_drawningWarmlyLocomotive.DrawTransport(getGraphics());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user