five commit
This commit is contained in:
parent
226955f1fe
commit
ea3315b4a9
@ -7,8 +7,8 @@ public class DrawingAir {
|
|||||||
return entityAir;
|
return entityAir;
|
||||||
}
|
}
|
||||||
private IDrawEngines drawingEngines;
|
private IDrawEngines drawingEngines;
|
||||||
private int _pictureWidth;
|
public int _pictureWidth;
|
||||||
private int _pictureHeight;
|
public int _pictureHeight;
|
||||||
protected int _startPosX;
|
protected int _startPosX;
|
||||||
public int getPosX(){return _startPosX;}
|
public int getPosX(){return _startPosX;}
|
||||||
protected int _startPosY;
|
protected int _startPosY;
|
||||||
@ -132,4 +132,15 @@ public class DrawingAir {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void ChangeColor(Color col){
|
||||||
|
entityAir.bodyColor = col;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ChangeIDraw(IDrawEngines obj){
|
||||||
|
drawingEngines = obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ChangeEnginesCol(int col){
|
||||||
|
drawingEngines.setNumber(col);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,9 @@ public class DrawingAirBomber extends DrawingAir {
|
|||||||
if(entityAir != null)
|
if(entityAir != null)
|
||||||
entityAir = new EntityAirBomber(speed, weight, bodyColor, additionalColor,rocket, toplivo);
|
entityAir = new EntityAirBomber(speed, weight, bodyColor, additionalColor,rocket, toplivo);
|
||||||
}
|
}
|
||||||
|
public void ChangeAddColor(Color col){
|
||||||
|
((EntityAirBomber)entityAir).additionalColor = col;
|
||||||
|
}
|
||||||
public void drawTransport(Graphics2D g)
|
public void drawTransport(Graphics2D g)
|
||||||
{
|
{
|
||||||
if (!(entityAir instanceof EntityAirBomber))
|
if (!(entityAir instanceof EntityAirBomber))
|
||||||
|
@ -9,7 +9,7 @@ public class EntityAir {
|
|||||||
public double getWeight() {
|
public double getWeight() {
|
||||||
return weight;
|
return weight;
|
||||||
}
|
}
|
||||||
private Color bodyColor;
|
public Color bodyColor;
|
||||||
public Color getBodyColor() {
|
public Color getBodyColor() {
|
||||||
return bodyColor;
|
return bodyColor;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public class EntityAirBomber extends EntityAir {
|
public class EntityAirBomber extends EntityAir {
|
||||||
private Color additionalColor;
|
public Color additionalColor;
|
||||||
public Color getAdditionalColor(){
|
public Color getAdditionalColor(){
|
||||||
return additionalColor;
|
return additionalColor;
|
||||||
}
|
}
|
||||||
|
387
src/FrameBomberConfig.java
Normal file
387
src/FrameBomberConfig.java
Normal file
@ -0,0 +1,387 @@
|
|||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.datatransfer.DataFlavor;
|
||||||
|
import java.awt.datatransfer.StringSelection;
|
||||||
|
import java.awt.datatransfer.Transferable;
|
||||||
|
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class FrameBomberConfig extends JFrame{
|
||||||
|
private static class LabelTransferHandler extends TransferHandler {
|
||||||
|
@Override
|
||||||
|
public int getSourceActions(JComponent c) {
|
||||||
|
return TransferHandler.COPY;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected Transferable createTransferable(JComponent c) {
|
||||||
|
return new StringSelection(((JLabel)c).getText());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private record ColorTransferable(Color color) implements Transferable {
|
||||||
|
private static final DataFlavor colorDataFlavor = new DataFlavor(Color.class, "Color");
|
||||||
|
@Override
|
||||||
|
public DataFlavor[] getTransferDataFlavors() {
|
||||||
|
return new DataFlavor[]{colorDataFlavor};
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean isDataFlavorSupported(DataFlavor flavor) {
|
||||||
|
return colorDataFlavor.equals(flavor);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
|
||||||
|
if (isDataFlavorSupported(flavor)) {
|
||||||
|
return color;
|
||||||
|
} else {
|
||||||
|
throw new UnsupportedFlavorException(flavor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private record IDrawEnginesTransferable(IDrawEngines IDrawEnginesObject) implements Transferable {
|
||||||
|
private static final DataFlavor IDrawEnginesDataFlavor = new DataFlavor(IDrawEngines.class, "IDrawEngines");
|
||||||
|
@Override
|
||||||
|
public DataFlavor[] getTransferDataFlavors() {
|
||||||
|
return new DataFlavor[]{IDrawEnginesDataFlavor};
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean isDataFlavorSupported(DataFlavor flavor) {
|
||||||
|
return IDrawEnginesDataFlavor.equals(flavor);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
|
||||||
|
if (isDataFlavorSupported(flavor)) {
|
||||||
|
return IDrawEnginesObject;
|
||||||
|
} else {
|
||||||
|
throw new UnsupportedFlavorException(flavor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static class PanelTransferHandler extends TransferHandler {
|
||||||
|
@Override
|
||||||
|
public int getSourceActions(JComponent c) {
|
||||||
|
return TransferHandler.COPY;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected Transferable createTransferable(JComponent c) {
|
||||||
|
return new ColorTransferable(c.getBackground());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static class LabelMouseAdapter extends MouseAdapter{
|
||||||
|
@Override
|
||||||
|
public void mousePressed(MouseEvent e) {
|
||||||
|
((JLabel)e.getComponent()).getTransferHandler().exportAsDrag(((JLabel)e.getComponent()), e, TransferHandler.COPY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static class PanelMouseAdapter extends MouseAdapter{
|
||||||
|
@Override
|
||||||
|
public void mousePressed(MouseEvent e) {
|
||||||
|
((JPanel)e.getComponent()).getTransferHandler().exportAsDrag(((JPanel)e.getComponent()), e, TransferHandler.COPY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static class IDrawEnginesComponent extends JComponent{
|
||||||
|
public IDrawEngines obj;
|
||||||
|
public IDrawEnginesComponent(IDrawEngines obj){
|
||||||
|
this.obj = obj;
|
||||||
|
this.addMouseListener(
|
||||||
|
new MouseAdapter(){
|
||||||
|
@Override
|
||||||
|
public void mousePressed(MouseEvent e) {
|
||||||
|
((IDrawEnginesComponent)e.getComponent()).getTransferHandler().exportAsDrag(((IDrawEnginesComponent)e.getComponent()), e, TransferHandler.COPY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
this.setTransferHandler(
|
||||||
|
new TransferHandler(){
|
||||||
|
@Override
|
||||||
|
public int getSourceActions(JComponent c) {
|
||||||
|
return TransferHandler.COPY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Transferable createTransferable(JComponent c) {
|
||||||
|
return new IDrawEnginesTransferable(((IDrawEnginesComponent) c).obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private final JComponent pictureBox = new JComponent(){
|
||||||
|
public void paintComponent(Graphics graphics){
|
||||||
|
super.paintComponent(graphics);
|
||||||
|
Graphics2D graphics2D = (Graphics2D) graphics;
|
||||||
|
if (drawingAir != null) drawingAir.drawTransport(graphics2D);
|
||||||
|
super.repaint();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
public final JButton addButton = new JButton("Добавить");
|
||||||
|
public final JButton cancelButton = new JButton("Отмена");
|
||||||
|
public DrawingAir drawingAir;
|
||||||
|
private final int pictureBoxWidth = 218;
|
||||||
|
private final int pictureBoxHeight = 178;
|
||||||
|
public FrameBomberConfig(){
|
||||||
|
super("Создание объекта");
|
||||||
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
createGui();
|
||||||
|
setVisible(true);
|
||||||
|
}
|
||||||
|
private void createGui(){
|
||||||
|
pictureBox.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
|
||||||
|
IDrawEnginesComponent engines = new IDrawEnginesComponent(new DrawingEnginesOval());
|
||||||
|
IDrawEnginesComponent enginesCircle = new IDrawEnginesComponent(new DrawingEnginesRound());
|
||||||
|
IDrawEnginesComponent enginesOval = new IDrawEnginesComponent(new DrawingEnginesSquare());
|
||||||
|
JLabel squareLabel = new JLabel("Квадратные");
|
||||||
|
squareLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
squareLabel.setVerticalAlignment(SwingConstants.CENTER);
|
||||||
|
JLabel roundedBackLabel = new JLabel("Круглые");
|
||||||
|
roundedBackLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
roundedBackLabel.setVerticalAlignment(SwingConstants.CENTER);
|
||||||
|
JLabel roundedFrontLabel = new JLabel("Овальные");
|
||||||
|
roundedFrontLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
roundedFrontLabel.setVerticalAlignment(SwingConstants.CENTER);
|
||||||
|
engines.setLayout(new GridLayout(1,1));
|
||||||
|
enginesCircle.setLayout(new GridLayout(1,1));
|
||||||
|
enginesOval.setLayout(new GridLayout(1,1));
|
||||||
|
engines.add(squareLabel);
|
||||||
|
enginesCircle.add(roundedBackLabel);
|
||||||
|
enginesOval.add(roundedFrontLabel);
|
||||||
|
engines.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
|
||||||
|
enginesCircle.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
|
||||||
|
enginesOval.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
|
||||||
|
JLabel colorLabel = new JLabel("Цвет");
|
||||||
|
colorLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
colorLabel.setVerticalAlignment(SwingConstants.CENTER);
|
||||||
|
colorLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
|
||||||
|
JLabel additionalColorLabel = new JLabel("Доп цвет");
|
||||||
|
additionalColorLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
additionalColorLabel.setVerticalAlignment(SwingConstants.CENTER);
|
||||||
|
additionalColorLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
|
||||||
|
JLabel IDrawEnginesLabel = new JLabel("Двигатели");
|
||||||
|
IDrawEnginesLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
IDrawEnginesLabel.setVerticalAlignment(SwingConstants.CENTER);
|
||||||
|
IDrawEnginesLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
|
||||||
|
JCheckBox checkBoxBomb = new JCheckBox("Наличие бомб");
|
||||||
|
JCheckBox checkBoxFuel = new JCheckBox("Наличие баков");
|
||||||
|
JLabel simpleLabel = new JLabel("Простой");
|
||||||
|
simpleLabel.setTransferHandler(new LabelTransferHandler());
|
||||||
|
simpleLabel.addMouseListener(new LabelMouseAdapter());
|
||||||
|
simpleLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
simpleLabel.setVerticalAlignment(SwingConstants.CENTER);
|
||||||
|
simpleLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
|
||||||
|
JLabel advancedLabel = new JLabel("Продвинутый");
|
||||||
|
advancedLabel.setTransferHandler(new LabelTransferHandler());
|
||||||
|
advancedLabel.addMouseListener(new LabelMouseAdapter());
|
||||||
|
advancedLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
advancedLabel.setVerticalAlignment(SwingConstants.CENTER);
|
||||||
|
advancedLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
|
||||||
|
JLabel speedLabel = new JLabel ("Скорость");
|
||||||
|
JLabel weightLabel = new JLabel ("Вес");
|
||||||
|
SpinnerNumberModel speedSpinnerModel = new SpinnerNumberModel(100.0, 100.0, 1000.0, 1.0);
|
||||||
|
SpinnerNumberModel weightSpinnerModel = new SpinnerNumberModel(100.0, 100.0, 1000.0, 1.0);
|
||||||
|
SpinnerNumberModel enginesNumberSpinnerModel = new SpinnerNumberModel(2, 2, 6, 2.0);
|
||||||
|
JSpinner speedSpinner = new JSpinner(speedSpinnerModel);
|
||||||
|
JSpinner weightSpinner = new JSpinner(weightSpinnerModel);
|
||||||
|
JSpinner enginesNumberSpinner = new JSpinner(enginesNumberSpinnerModel);
|
||||||
|
JPanel colorPanel = new JPanel();
|
||||||
|
JPanel redPanel = new JPanel();
|
||||||
|
JPanel greenPanel = new JPanel();
|
||||||
|
JPanel bluePanel = new JPanel();
|
||||||
|
JPanel yellowPanel = new JPanel();
|
||||||
|
JPanel whitePanel = new JPanel();
|
||||||
|
JPanel grayPanel = new JPanel();
|
||||||
|
JPanel blackPanel = new JPanel();
|
||||||
|
JPanel purplePanel = new JPanel();
|
||||||
|
redPanel.setTransferHandler(new PanelTransferHandler());
|
||||||
|
greenPanel.setTransferHandler(new PanelTransferHandler());
|
||||||
|
bluePanel.setTransferHandler(new PanelTransferHandler());
|
||||||
|
yellowPanel.setTransferHandler(new PanelTransferHandler());
|
||||||
|
whitePanel.setTransferHandler(new PanelTransferHandler());
|
||||||
|
grayPanel.setTransferHandler(new PanelTransferHandler());
|
||||||
|
blackPanel.setTransferHandler(new PanelTransferHandler());
|
||||||
|
purplePanel.setTransferHandler(new PanelTransferHandler());
|
||||||
|
redPanel.addMouseListener(new PanelMouseAdapter());
|
||||||
|
greenPanel.addMouseListener(new PanelMouseAdapter());
|
||||||
|
bluePanel.addMouseListener(new PanelMouseAdapter());
|
||||||
|
yellowPanel.addMouseListener(new PanelMouseAdapter());
|
||||||
|
whitePanel.addMouseListener(new PanelMouseAdapter());
|
||||||
|
grayPanel.addMouseListener(new PanelMouseAdapter());
|
||||||
|
blackPanel.addMouseListener(new PanelMouseAdapter());
|
||||||
|
purplePanel.addMouseListener(new PanelMouseAdapter());
|
||||||
|
redPanel.setName("Красный");
|
||||||
|
greenPanel.setName("Зелёный");
|
||||||
|
bluePanel.setName("Синий");
|
||||||
|
yellowPanel.setName("Жёлтый");
|
||||||
|
whitePanel.setName("Белый");
|
||||||
|
grayPanel.setName("Серый");
|
||||||
|
blackPanel.setName("Чёрный");
|
||||||
|
purplePanel.setName("Фиолетовый");
|
||||||
|
pictureBox.setTransferHandler(
|
||||||
|
new TransferHandler(){
|
||||||
|
@Override
|
||||||
|
public boolean canImport(TransferSupport support) {
|
||||||
|
return support.isDataFlavorSupported(DataFlavor.stringFlavor);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean importData(TransferSupport support) {
|
||||||
|
if (canImport(support)) {
|
||||||
|
try {
|
||||||
|
int speed = ((Number)speedSpinner.getValue()).intValue();
|
||||||
|
int weight = ((Number)weightSpinner.getValue()).intValue();
|
||||||
|
int enginesNumber = ((Number)enginesNumberSpinner.getValue()).intValue();
|
||||||
|
switch ((String)support.getTransferable().getTransferData(DataFlavor.stringFlavor)) {
|
||||||
|
case "Простой" -> {
|
||||||
|
drawingAir = new DrawingAir(speed, weight, Color.WHITE,
|
||||||
|
pictureBoxWidth, pictureBoxHeight, 0, enginesNumber);
|
||||||
|
drawingAir.ChangeEnginesCol(enginesNumber);
|
||||||
|
}
|
||||||
|
case "Продвинутый" -> {
|
||||||
|
drawingAir = new DrawingAirBomber(speed, weight, Color.WHITE, Color.BLACK,
|
||||||
|
checkBoxBomb.isSelected(), checkBoxFuel.isSelected(),
|
||||||
|
pictureBoxWidth, pictureBoxHeight, 0, enginesNumber);
|
||||||
|
drawingAir.ChangeEnginesCol(enginesNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
drawingAir.setPosition(pictureBoxWidth / 2 - drawingAir.getWidth() / 2,
|
||||||
|
pictureBoxHeight / 2 - drawingAir.getHeight() / 2);
|
||||||
|
pictureBox.repaint();
|
||||||
|
return true;
|
||||||
|
} catch (UnsupportedFlavorException | IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
IDrawEnginesLabel.setTransferHandler(
|
||||||
|
new TransferHandler(){
|
||||||
|
@Override
|
||||||
|
public boolean canImport(TransferSupport support) {
|
||||||
|
return support.isDataFlavorSupported(IDrawEnginesTransferable.IDrawEnginesDataFlavor);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean importData(TransferSupport support) {
|
||||||
|
if (canImport(support)) {
|
||||||
|
try {
|
||||||
|
IDrawEngines obj = (IDrawEngines) support.getTransferable().getTransferData(IDrawEnginesTransferable.IDrawEnginesDataFlavor);
|
||||||
|
obj.setNumber(((Number)enginesNumberSpinner.getValue()).intValue());
|
||||||
|
if (drawingAir == null)
|
||||||
|
return false;
|
||||||
|
drawingAir.ChangeIDraw(obj);
|
||||||
|
pictureBox.repaint();
|
||||||
|
return true;
|
||||||
|
} catch (UnsupportedFlavorException | IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
colorLabel.setTransferHandler(
|
||||||
|
new TransferHandler(){
|
||||||
|
@Override
|
||||||
|
public boolean canImport(TransferSupport support) {
|
||||||
|
return support.isDataFlavorSupported(ColorTransferable.colorDataFlavor);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean importData(TransferSupport support) {
|
||||||
|
if (canImport(support)) {
|
||||||
|
try {
|
||||||
|
Color color = (Color) support.getTransferable().getTransferData(ColorTransferable.colorDataFlavor);
|
||||||
|
if (drawingAir == null)
|
||||||
|
return false;
|
||||||
|
drawingAir.ChangeColor(color);
|
||||||
|
pictureBox.repaint();
|
||||||
|
return true;
|
||||||
|
} catch (UnsupportedFlavorException | IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
additionalColorLabel.setTransferHandler(
|
||||||
|
new TransferHandler(){
|
||||||
|
@Override
|
||||||
|
public boolean canImport(TransferSupport support) {
|
||||||
|
return support.isDataFlavorSupported(ColorTransferable.colorDataFlavor);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean importData(TransferSupport support) {
|
||||||
|
if (canImport(support)) {
|
||||||
|
try {
|
||||||
|
Color color = (Color) support.getTransferable().getTransferData(ColorTransferable.colorDataFlavor);
|
||||||
|
if (drawingAir == null || !(drawingAir instanceof DrawingAirBomber))
|
||||||
|
return false;
|
||||||
|
((DrawingAirBomber) drawingAir).ChangeAddColor(color);
|
||||||
|
pictureBox.repaint();
|
||||||
|
return true;
|
||||||
|
} catch (UnsupportedFlavorException | IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
addButton.setBounds(555,250,94,29);
|
||||||
|
cancelButton.setBounds(679,250,94,29);
|
||||||
|
pictureBox.setBounds(555, 65, pictureBoxWidth, pictureBoxHeight);
|
||||||
|
colorLabel.setBounds(555, 20, 70, 33);
|
||||||
|
additionalColorLabel.setBounds(629, 20, 70, 33);
|
||||||
|
IDrawEnginesLabel.setBounds(703, 20, 70, 33);
|
||||||
|
checkBoxBomb.setBounds(6, 132, 159, 24);
|
||||||
|
checkBoxFuel.setBounds(6, 162, 145, 24);
|
||||||
|
simpleLabel.setBounds(171,229, 120, 50);
|
||||||
|
advancedLabel.setBounds(297,229, 120, 50);
|
||||||
|
engines.setBounds(171,169, 120, 50);
|
||||||
|
enginesCircle.setBounds(297,169, 120, 50);
|
||||||
|
enginesOval.setBounds(423,169, 120, 50);
|
||||||
|
colorPanel.setBounds(171, 23, 300,120);
|
||||||
|
speedSpinner.setBounds(6, 46, 150, 27);
|
||||||
|
speedLabel.setBounds(6, 23, 73, 20);
|
||||||
|
weightSpinner.setBounds(6, 99, 150, 27);
|
||||||
|
weightLabel.setBounds(6, 76, 33, 20);
|
||||||
|
enginesNumberSpinner.setBounds(6, 200, 150, 27);
|
||||||
|
redPanel.setBackground(Color.RED);
|
||||||
|
greenPanel.setBackground(Color.GREEN);
|
||||||
|
bluePanel.setBackground(Color.BLUE);
|
||||||
|
yellowPanel.setBackground(Color.YELLOW);
|
||||||
|
whitePanel.setBackground(Color.WHITE);
|
||||||
|
grayPanel.setBackground(Color.GRAY);
|
||||||
|
blackPanel.setBackground(Color.BLACK);
|
||||||
|
purplePanel.setBackground(Color.MAGENTA);
|
||||||
|
colorPanel.setLayout(new GridLayout(2, 4, 26, 10));
|
||||||
|
colorPanel.add(redPanel);
|
||||||
|
colorPanel.add(greenPanel);
|
||||||
|
colorPanel.add(bluePanel);
|
||||||
|
colorPanel.add(yellowPanel);
|
||||||
|
colorPanel.add(whitePanel);
|
||||||
|
colorPanel.add(grayPanel);
|
||||||
|
colorPanel.add(blackPanel);
|
||||||
|
colorPanel.add(purplePanel);
|
||||||
|
add(colorLabel);
|
||||||
|
add(additionalColorLabel);
|
||||||
|
add(IDrawEnginesLabel);
|
||||||
|
setLayout(null);
|
||||||
|
setSize(818, 350);
|
||||||
|
add(speedLabel);
|
||||||
|
add(speedSpinner);
|
||||||
|
add(weightLabel);
|
||||||
|
add(weightSpinner);
|
||||||
|
add(simpleLabel);
|
||||||
|
add(advancedLabel);
|
||||||
|
add(checkBoxBomb);
|
||||||
|
add(checkBoxFuel);
|
||||||
|
add(pictureBox);
|
||||||
|
add(addButton);
|
||||||
|
add(cancelButton);
|
||||||
|
add(enginesNumberSpinner);
|
||||||
|
add(colorPanel);
|
||||||
|
add(engines);
|
||||||
|
add(enginesCircle);
|
||||||
|
add(enginesOval);
|
||||||
|
}
|
||||||
|
}
|
@ -136,30 +136,22 @@ public class FramePlaneCollection extends JFrame {
|
|||||||
storage.DelSet(listStorages.getSelectedValue());
|
storage.DelSet(listStorages.getSelectedValue());
|
||||||
reloadObjects();
|
reloadObjects();
|
||||||
}
|
}
|
||||||
private void buttonAddPlaneClick() {
|
public void buttonAddPlaneClick() {
|
||||||
if (listStorages.getSelectedIndex() == -1)
|
BomberGenericCollection<DrawingAir, DrawingObjectPlane> drawingPlanes = storage.getCollection(listStorages.getSelectedValue());
|
||||||
return;
|
FrameBomberConfig framePlaneConfig = new FrameBomberConfig();
|
||||||
var obj = storage.getCollection(listStorages.getSelectedValue());
|
framePlaneConfig.addButton.addActionListener(e -> {
|
||||||
if (obj == null)
|
if (drawingPlanes.Insert(framePlaneConfig.drawingAir)) {
|
||||||
return;
|
framePlaneConfig.dispose();
|
||||||
FrameAirBomber form;
|
framePlaneConfig.drawingAir._pictureWidth = pictureBoxCollection.getWidth();
|
||||||
try {
|
framePlaneConfig.drawingAir._pictureHeight = pictureBoxCollection.getHeight();
|
||||||
form = new FrameAirBomber();
|
JOptionPane.showMessageDialog(null, "Объект добавлен", "Информация", JOptionPane.INFORMATION_MESSAGE);
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
form.selectPlaneButton.addActionListener(e->{
|
|
||||||
form.select();
|
|
||||||
DrawingAir plane = form.getSelectedPlane();
|
|
||||||
form.dispose();
|
|
||||||
if (obj.Insert(plane)) {
|
|
||||||
JOptionPane.showMessageDialog(this, "Объект добавлен");
|
|
||||||
pictureBoxCollection.repaint();
|
pictureBoxCollection.repaint();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
JOptionPane.showMessageDialog(this, "Не удалось добавить объект");
|
JOptionPane.showMessageDialog(null, "Не удалось добавить объект", "Информация", JOptionPane.INFORMATION_MESSAGE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
framePlaneConfig.cancelButton.addActionListener(e -> framePlaneConfig.dispose());
|
||||||
}
|
}
|
||||||
private void buttonRemovePlaneClick(){
|
private void buttonRemovePlaneClick(){
|
||||||
if (listStorages.getSelectedIndex() == -1)
|
if (listStorages.getSelectedIndex() == -1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user