тепловозы появляются
This commit is contained in:
parent
490b9151ce
commit
b672e4c67b
@ -1,5 +1,6 @@
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
|
|
||||||
public class DrawingWarmlyLocomotive {
|
public class DrawingWarmlyLocomotive {
|
||||||
|
|
||||||
private EntityWarmlyLocomotive EntityWarmlyLocomotive;
|
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.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
public class FormWarmlyLocomotive extends JFrame {
|
public class FormWarmlyLocomotive extends JFrame {
|
||||||
|
DrawingWarmlyLocomotive _drawningWarmlyLocomotive;
|
||||||
|
JPanel pictureBox;
|
||||||
|
|
||||||
public void Initialize(){
|
public void Initialize(){
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
@ -10,14 +17,25 @@ public class FormWarmlyLocomotive extends JFrame {
|
|||||||
setResizable(false);
|
setResizable(false);
|
||||||
|
|
||||||
//pictireBox
|
//pictireBox
|
||||||
JPanel pictureBox = new JPanel();
|
pictureBox = new JPanel();
|
||||||
pictureBox.setSize(getWidth(), getHeight());
|
pictureBox.setSize(getWidth(), getHeight());
|
||||||
pictureBox.setLayout(null);
|
pictureBox.setLayout(null);
|
||||||
|
|
||||||
//createButton
|
//createButton
|
||||||
JButton createButton = new JButton("Создать");
|
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);
|
pictureBox.add(createButton);
|
||||||
|
|
||||||
|
|
||||||
//upButton
|
//upButton
|
||||||
JButton upButton = new JButton();
|
JButton upButton = new JButton();
|
||||||
@ -52,6 +70,38 @@ public class FormWarmlyLocomotive extends JFrame {
|
|||||||
pictureBox.add(leftButton);
|
pictureBox.add(leftButton);
|
||||||
repaint();
|
repaint();
|
||||||
add(pictureBox);
|
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