Готовая лабораторная 3
This commit is contained in:
parent
7539e7f88b
commit
44a103ee4c
@ -6,24 +6,24 @@ import java.awt.event.ActionListener;
|
|||||||
public class FormTankGenerate extends JFrame {
|
public class FormTankGenerate extends JFrame {
|
||||||
static int pictureBoxWidth = 560;
|
static int pictureBoxWidth = 560;
|
||||||
static int pictureBoxHeight = 560;
|
static int pictureBoxHeight = 560;
|
||||||
public DrawingArmoVehicle _drawingTank;
|
public DrawingArmoVehicle _drawingVehicle;
|
||||||
private class Canvas extends JComponent{
|
private class Canvas extends JComponent{
|
||||||
public Canvas() {
|
public Canvas() {
|
||||||
}
|
}
|
||||||
public void paintComponent (Graphics g){
|
public void paintComponent (Graphics g){
|
||||||
if (_drawingTank == null){
|
if (_drawingVehicle == null){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
super.paintComponents (g) ;
|
super.paintComponents (g) ;
|
||||||
Graphics2D g2d = (Graphics2D)g;
|
Graphics2D g2d = (Graphics2D)g;
|
||||||
_drawingTank.SetPosition(250, 250);
|
_drawingVehicle.SetPosition(250, 250);
|
||||||
_drawingTank.DrawTransport(g2d);
|
_drawingVehicle.DrawTransport(g2d);
|
||||||
super.repaint();
|
super.repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DoubleParametrized<EntityArmoVehicle, IOrnamentForm> genericTankGenerate;
|
DoubleParametrized<EntityArmoVehicle, IOrnamentForm> genericTankGenerate;
|
||||||
public FormTankGenerate(){
|
public FormTankGenerate(){
|
||||||
_drawingTank = null;
|
_drawingVehicle = null;
|
||||||
Canvas canv = new Canvas();
|
Canvas canv = new Canvas();
|
||||||
setSize (640, 640);
|
setSize (640, 640);
|
||||||
setLayout(null);
|
setLayout(null);
|
||||||
@ -37,19 +37,19 @@ public class FormTankGenerate extends JFrame {
|
|||||||
genericTankGenerate.Add(new DrawingStarOrnament());
|
genericTankGenerate.Add(new DrawingStarOrnament());
|
||||||
genericTankGenerate.Add(new DrawingWheelsCombination());
|
genericTankGenerate.Add(new DrawingWheelsCombination());
|
||||||
|
|
||||||
JButton creatButton = new JButton("Сгенерировать");
|
JButton createButton = new JButton("Сгенерировать");
|
||||||
creatButton.addActionListener(
|
createButton.addActionListener(
|
||||||
new ActionListener() {
|
new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e){
|
public void actionPerformed(ActionEvent e){
|
||||||
_drawingTank = genericTankGenerate.GenerateTank(pictureBoxWidth,pictureBoxHeight);
|
_drawingVehicle = genericTankGenerate.GenerateTank(pictureBoxWidth,pictureBoxHeight);
|
||||||
canv.repaint();
|
canv.repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
creatButton.setBounds(pictureBoxWidth/2 - 40, pictureBoxHeight-20, 180, 20);
|
createButton.setBounds(pictureBoxWidth/2 - 40, pictureBoxHeight-20, 180, 20);
|
||||||
|
|
||||||
add(canv);
|
add(canv);
|
||||||
add(creatButton);
|
add(createButton);
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user