создана форма
This commit is contained in:
parent
791d5205b3
commit
646ecece61
@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="JAVA_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
205
src/FormAirbusConfig.java
Normal file
205
src/FormAirbusConfig.java
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.border.Border;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class FormAirbusConfig extends JFrame {
|
||||||
|
|
||||||
|
FormAirbusConfig() {
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
private void InitializeComponent() {
|
||||||
|
// инициализация
|
||||||
|
Random rand = new Random();
|
||||||
|
frame = new JFrame("Конструирование самолёта");
|
||||||
|
canvas = new Canvas();
|
||||||
|
groupBoxConfig = new JPanel();
|
||||||
|
groupBoxColors = new JPanel();
|
||||||
|
panelObject = new JPanel();
|
||||||
|
panelRed = new JPanel();
|
||||||
|
panelYellow = new JPanel();
|
||||||
|
panelBlue = new JPanel();
|
||||||
|
panelViolet = new JPanel();
|
||||||
|
panelGreen = new JPanel();
|
||||||
|
panelWhite = new JPanel();
|
||||||
|
panelOrange = new JPanel();
|
||||||
|
panelSilver = new JPanel();
|
||||||
|
labelAdditionalColor = new JLabel("Доп.цвет", SwingConstants.CENTER);
|
||||||
|
labelBodyColor = new JLabel("Основной цвет", SwingConstants.CENTER);
|
||||||
|
labelSimpleObject = new JLabel("Простой", SwingConstants.CENTER);
|
||||||
|
labelComplexObject = new JLabel("Продвинутый", SwingConstants.CENTER);
|
||||||
|
labelSpeed = new JLabel("Скорость: ");
|
||||||
|
labelWeight = new JLabel("Вес: ");
|
||||||
|
buttonOk = new JButton("Добавить");
|
||||||
|
buttonCancel = new JButton("Отмена");
|
||||||
|
checkBoxAdditionalEngine = new JCheckBox("Добавить доп. двигатель");
|
||||||
|
checkBoxCompartment = new JCheckBox("Добавить пассажирский отсек");
|
||||||
|
spinnerModelSpeed = new SpinnerNumberModel(rand.nextInt(900)+100, 100.0, 1000.0, 1.0);
|
||||||
|
numericUpDownSpeed = new JSpinner(spinnerModelSpeed);
|
||||||
|
spinnerModelWeight = new SpinnerNumberModel(rand.nextInt(1000)+100, 100.0, 1000.0, 1.0);
|
||||||
|
numericUpDownWeight = new JSpinner(spinnerModelWeight);
|
||||||
|
|
||||||
|
// реализация
|
||||||
|
// groupBoxConfig
|
||||||
|
groupBoxConfig.setBorder(BorderFactory.createTitledBorder("Параметры"));
|
||||||
|
groupBoxConfig.setSize(620, 243);
|
||||||
|
groupBoxConfig.setLocation(24, 16);
|
||||||
|
groupBoxConfig.setLayout(null);
|
||||||
|
groupBoxConfig.add(numericUpDownSpeed);
|
||||||
|
groupBoxConfig.add(numericUpDownWeight);
|
||||||
|
groupBoxConfig.add(labelSpeed);
|
||||||
|
groupBoxConfig.add(labelWeight);
|
||||||
|
groupBoxConfig.add(checkBoxAdditionalEngine);
|
||||||
|
groupBoxConfig.add(checkBoxCompartment);
|
||||||
|
groupBoxConfig.add(groupBoxColors);
|
||||||
|
groupBoxConfig.add(groupBoxColors);
|
||||||
|
groupBoxConfig.add(labelSimpleObject);
|
||||||
|
groupBoxConfig.add(labelComplexObject);
|
||||||
|
// numericUpDownSpeed
|
||||||
|
numericUpDownSpeed.setSize(79, 27);
|
||||||
|
numericUpDownSpeed.setLocation(106, 41);
|
||||||
|
// numericUpDownWeight
|
||||||
|
numericUpDownWeight.setSize(79, 27);
|
||||||
|
numericUpDownWeight.setLocation(106, 88);
|
||||||
|
// checkBoxAdditionalEngine
|
||||||
|
checkBoxAdditionalEngine.setSize(204, 24);
|
||||||
|
checkBoxAdditionalEngine.setLocation(22, 151);
|
||||||
|
// checkBoxCompartment
|
||||||
|
checkBoxCompartment.setSize(204, 24);
|
||||||
|
checkBoxCompartment.setLocation(22, 186);
|
||||||
|
// labelSpeed
|
||||||
|
labelSpeed.setSize(80, 20);
|
||||||
|
labelSpeed.setLocation(22, 43);
|
||||||
|
// labelWeight
|
||||||
|
labelWeight.setSize(36, 20);
|
||||||
|
labelWeight.setLocation(22, 95);
|
||||||
|
// groupBoxColors
|
||||||
|
groupBoxColors.setBorder(BorderFactory.createTitledBorder("Цвета"));
|
||||||
|
groupBoxColors.setSize(279, 155);
|
||||||
|
groupBoxColors.setLocation(310, 21);
|
||||||
|
groupBoxColors.add(panelRed);
|
||||||
|
groupBoxColors.add(panelYellow);
|
||||||
|
groupBoxColors.add(panelBlue);
|
||||||
|
groupBoxColors.add(panelViolet);
|
||||||
|
groupBoxColors.add(panelGreen);
|
||||||
|
groupBoxColors.add(panelSilver);
|
||||||
|
groupBoxColors.add(panelOrange);
|
||||||
|
groupBoxColors.add(panelWhite);
|
||||||
|
groupBoxColors.setLayout(null);
|
||||||
|
// panelRed
|
||||||
|
panelRed.setBackground(Color.RED);
|
||||||
|
panelRed.setSize(40, 40);
|
||||||
|
panelRed.setLocation(38, 43);
|
||||||
|
// panelYellow
|
||||||
|
panelYellow.setBackground(Color.YELLOW);
|
||||||
|
panelYellow.setSize(40, 40);
|
||||||
|
panelYellow.setLocation(93, 43);
|
||||||
|
// panelBlue
|
||||||
|
panelBlue.setBackground(Color.BLUE);
|
||||||
|
panelBlue.setSize(40, 40);
|
||||||
|
panelBlue.setLocation(148, 43);
|
||||||
|
// panelViolet
|
||||||
|
panelViolet.setBackground(Color.MAGENTA);
|
||||||
|
panelViolet.setSize(40, 40);
|
||||||
|
panelViolet.setLocation(204, 43);
|
||||||
|
// panelGreen
|
||||||
|
panelGreen.setBackground(Color.GREEN);
|
||||||
|
panelGreen.setSize(40, 40);
|
||||||
|
panelGreen.setLocation(38, 96);
|
||||||
|
// panelSilver
|
||||||
|
panelSilver.setBackground(Color.LIGHT_GRAY);
|
||||||
|
panelSilver.setSize(40, 40);
|
||||||
|
panelSilver.setLocation(148, 96);
|
||||||
|
// panelOrange
|
||||||
|
panelOrange.setBackground(Color.ORANGE);
|
||||||
|
panelOrange.setSize(40, 40);
|
||||||
|
panelOrange.setLocation(204, 96);
|
||||||
|
// panelWhite
|
||||||
|
panelWhite.setBackground(Color.WHITE);
|
||||||
|
panelWhite.setSize(40, 40);
|
||||||
|
panelWhite.setLocation(93, 96);
|
||||||
|
|
||||||
|
colorPanels = new JPanel[]{
|
||||||
|
panelRed, panelYellow, panelBlue, panelViolet,
|
||||||
|
panelGreen, panelWhite, panelOrange, panelSilver,
|
||||||
|
};
|
||||||
|
|
||||||
|
// labelComplexObject
|
||||||
|
labelComplexObject.setSize(120, 38);
|
||||||
|
labelComplexObject.setLocation(464, 185);
|
||||||
|
labelComplexObject.setBorder(BorderFactory.createLineBorder(Color.lightGray));
|
||||||
|
// labelSimpleObject
|
||||||
|
labelSimpleObject.setSize(120, 38);
|
||||||
|
labelSimpleObject.setLocation(314, 185);
|
||||||
|
labelSimpleObject.setBorder(BorderFactory.createLineBorder(Color.lightGray));
|
||||||
|
// buttonOk
|
||||||
|
buttonOk.setSize(107, 43);
|
||||||
|
buttonOk.setLocation(666, 212);
|
||||||
|
// buttonCancel
|
||||||
|
buttonCancel.setSize(107, 43);
|
||||||
|
buttonCancel.setLocation(796, 212);
|
||||||
|
// labelBodyColor
|
||||||
|
labelBodyColor.setSize(107, 38);
|
||||||
|
labelBodyColor.setLocation(18, 9);
|
||||||
|
labelBodyColor.setBorder(BorderFactory.createLineBorder(Color.lightGray));
|
||||||
|
// labelAdditionalColor
|
||||||
|
labelAdditionalColor.setSize(107, 38);
|
||||||
|
labelAdditionalColor.setLocation(138, 9);
|
||||||
|
labelAdditionalColor.setBorder(BorderFactory.createLineBorder(Color.lightGray));
|
||||||
|
// panelObject
|
||||||
|
panelObject.setSize(264, 171);
|
||||||
|
panelObject.setLocation(650, 21);
|
||||||
|
panelObject.setBorder(BorderFactory.createLineBorder(Color.lightGray));
|
||||||
|
panelObject.add(labelAdditionalColor);
|
||||||
|
panelObject.add(labelBodyColor);
|
||||||
|
panelObject.add(canvas);
|
||||||
|
panelObject.setLayout(null);
|
||||||
|
|
||||||
|
// FormAirbusConfig
|
||||||
|
frame.setSize(952, 313);
|
||||||
|
frame.setLayout(null);
|
||||||
|
frame.add(groupBoxConfig);
|
||||||
|
frame.add(panelObject);
|
||||||
|
frame.add(buttonOk);
|
||||||
|
frame.add(buttonCancel);
|
||||||
|
frame.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
class Canvas extends JComponent {
|
||||||
|
public Canvas() {}
|
||||||
|
|
||||||
|
public void paintComponent(Graphics g) {
|
||||||
|
super.paintComponents(g);
|
||||||
|
super.repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private JFrame frame;
|
||||||
|
private Canvas canvas;
|
||||||
|
private JPanel groupBoxConfig;
|
||||||
|
private JSpinner numericUpDownWeight;
|
||||||
|
private SpinnerModel spinnerModelWeight;
|
||||||
|
private JSpinner numericUpDownSpeed;
|
||||||
|
private SpinnerModel spinnerModelSpeed;
|
||||||
|
private JCheckBox checkBoxAdditionalEngine;
|
||||||
|
private JCheckBox checkBoxCompartment;
|
||||||
|
private JLabel labelWeight;
|
||||||
|
private JLabel labelSpeed;
|
||||||
|
private JPanel groupBoxColors;
|
||||||
|
private JPanel[] colorPanels;
|
||||||
|
private JPanel panelRed;
|
||||||
|
private JPanel panelYellow;
|
||||||
|
private JPanel panelBlue;
|
||||||
|
private JPanel panelViolet;
|
||||||
|
private JPanel panelGreen;
|
||||||
|
private JPanel panelWhite;
|
||||||
|
private JPanel panelOrange;
|
||||||
|
private JPanel panelSilver;
|
||||||
|
private JLabel labelComplexObject;
|
||||||
|
private JLabel labelSimpleObject;
|
||||||
|
private JLabel labelBodyColor;
|
||||||
|
private JLabel labelAdditionalColor;
|
||||||
|
private JButton buttonOk;
|
||||||
|
private JButton buttonCancel;
|
||||||
|
private JPanel panelObject;
|
||||||
|
}
|
@ -1,5 +1,4 @@
|
|||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new FormAirbusCollection();
|
new FormAirbusCollection();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user