Сверстали форму с конфигами, украшаем

This commit is contained in:
Данила Мочалов 2022-11-15 17:10:04 +04:00
parent 9262f67b28
commit 6e69f8b100
3 changed files with 399 additions and 1 deletions

View File

@ -107,6 +107,6 @@ public class FormLocomotive extends JComponent{
super.repaint(); super.repaint();
} }
public static void main(String[] args) { public static void main(String[] args) {
new FormMapWithSetLocomotives(); new FormLocomotiveConfig();
} }
} }

337
FormLocomotiveConfig.form Normal file
View File

@ -0,0 +1,337 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="FormLocomotiveConfig">
<grid id="27dc6" binding="FormPanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="688" height="485"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="1add4" binding="ParametersPanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none" title="Parameters"/>
<children>
<grid id="ac7f6" binding="ColorPanel" layout-manager="GridLayoutManager" row-count="3" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none" title="Color Pick"/>
<children>
<grid id="56efb" binding="RedColorPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<minimum-size width="50" height="50"/>
<maximum-size width="50" height="50"/>
</grid>
</constraints>
<properties>
<background color="-65536"/>
</properties>
<border type="none"/>
<children/>
</grid>
<grid id="49a9d" binding="GreenColorPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<minimum-size width="50" height="50"/>
<maximum-size width="50" height="50"/>
</grid>
</constraints>
<properties>
<background color="-16711936"/>
</properties>
<border type="none"/>
<children/>
</grid>
<grid id="94ada" binding="BlueColorPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<minimum-size width="50" height="50"/>
<maximum-size width="50" height="50"/>
</grid>
</constraints>
<properties>
<background color="-16776961"/>
</properties>
<border type="none"/>
<children/>
</grid>
<grid id="39e91" binding="YellowColorPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<minimum-size width="50" height="50"/>
<maximum-size width="50" height="50"/>
</grid>
</constraints>
<properties>
<background color="-256"/>
</properties>
<border type="none"/>
<children/>
</grid>
<grid id="20acf" binding="WhiteColorPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<minimum-size width="50" height="50"/>
<maximum-size width="50" height="50"/>
</grid>
</constraints>
<properties>
<background color="-1"/>
</properties>
<border type="none"/>
<children/>
</grid>
<grid id="5cd7b" binding="BlackColorPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<minimum-size width="50" height="50"/>
<maximum-size width="50" height="50"/>
</grid>
</constraints>
<properties>
<background color="-16777216"/>
</properties>
<border type="none"/>
<children/>
</grid>
<grid id="54ec4" binding="AquaColorPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<minimum-size width="50" height="50"/>
<maximum-size width="50" height="50"/>
</grid>
</constraints>
<properties>
<background color="-16711681"/>
</properties>
<border type="none"/>
<children/>
</grid>
<grid id="5bf58" binding="PurpleColorPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<minimum-size width="50" height="50"/>
<maximum-size width="50" height="50"/>
</grid>
</constraints>
<properties>
<background color="-65281"/>
</properties>
<border type="none"/>
<children/>
</grid>
<vspacer id="47a2">
<constraints>
<grid row="2" column="0" row-span="1" col-span="4" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
</children>
</grid>
<grid id="97483" binding="StatsPanel" layout-manager="GridLayoutManager" row-count="10" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none" title="Stats"/>
<children>
<component id="a2b73" class="javax.swing.JLabel" binding="SpeedLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Speed:"/>
</properties>
</component>
<component id="63e1f" class="javax.swing.JSpinner" binding="SpeedSpinner">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="4677d" class="javax.swing.JLabel" binding="WeightLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Weight:"/>
</properties>
</component>
<component id="dd3cf" class="javax.swing.JSpinner" binding="WeightSpinner">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="d60f6" class="javax.swing.JCheckBox" binding="PipeCheckBox">
<constraints>
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Add Pipe"/>
</properties>
</component>
<component id="91766" class="javax.swing.JCheckBox" binding="FuelCheckBox">
<constraints>
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Add Fuel Storage"/>
</properties>
</component>
<component id="cb567" class="javax.swing.JLabel" binding="SimpleObjectLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false">
<minimum-size width="100" height="50"/>
</grid>
</constraints>
<properties>
<horizontalAlignment value="0"/>
<horizontalTextPosition value="0"/>
<text value="Simple "/>
</properties>
</component>
<component id="8c3ff" class="javax.swing.JLabel" binding="AdvancedObjectLabel">
<constraints>
<grid row="5" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false">
<minimum-size width="100" height="50"/>
</grid>
</constraints>
<properties>
<horizontalAlignment value="0"/>
<horizontalTextPosition value="0"/>
<text value="Advanced"/>
</properties>
</component>
<component id="d7166" class="javax.swing.JLabel" binding="SimpleWheelsLabel">
<constraints>
<grid row="6" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false">
<minimum-size width="100" height="50"/>
</grid>
</constraints>
<properties>
<horizontalAlignment value="0"/>
<horizontalTextPosition value="0"/>
<text value="SimpleWheels"/>
</properties>
</component>
<component id="b76f1" class="javax.swing.JLabel" binding="StarWheelsLabel">
<constraints>
<grid row="7" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false">
<minimum-size width="100" height="50"/>
</grid>
</constraints>
<properties>
<horizontalAlignment value="0"/>
<horizontalTextPosition value="0"/>
<text value="StarWheels"/>
</properties>
</component>
<component id="a09d0" class="javax.swing.JLabel" binding="RoundWheelsLabel">
<constraints>
<grid row="8" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false">
<minimum-size width="100" height="50"/>
</grid>
</constraints>
<properties>
<horizontalAlignment value="0"/>
<horizontalTextPosition value="0"/>
<text value="RoundWheels"/>
</properties>
</component>
<component id="55da5" class="javax.swing.JSpinner" binding="WheelsCountSpinner">
<constraints>
<grid row="9" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="5c650" class="javax.swing.JLabel" binding="WheelsCountLabel">
<constraints>
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="WheelsCount"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
<grid id="ddc6e" binding="CreatePanel" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none" title="Create"/>
<children>
<component id="81e87" class="javax.swing.JLabel" binding="MainColorLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false">
<minimum-size width="100" height="50"/>
</grid>
</constraints>
<properties>
<horizontalAlignment value="0"/>
<horizontalTextPosition value="0"/>
<text value="BaseColor"/>
</properties>
</component>
<component id="b3269" class="javax.swing.JLabel" binding="ExtraColorLabel">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false">
<minimum-size width="100" height="50"/>
</grid>
</constraints>
<properties>
<horizontalAlignment value="0"/>
<horizontalTextPosition value="0"/>
<text value="ExtraColor"/>
</properties>
</component>
<grid id="4dc4a" binding="ObjectViewPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
<component id="c9686" class="javax.swing.JButton" binding="AddButton">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Add"/>
</properties>
</component>
<component id="ff438" class="javax.swing.JButton" binding="CancelButton">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Cancel"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</form>

61
FormLocomotiveConfig.java Normal file
View File

@ -0,0 +1,61 @@
import javax.swing.*;
import java.awt.*;
public class FormLocomotiveConfig extends JFrame{
private JPanel FormPanel;
private JPanel ParametersPanel;
private JPanel CreatePanel;
private JPanel ColorPanel;
private JPanel StatsPanel;
private JLabel SpeedLabel;
private JSpinner SpeedSpinner;
private JLabel WeightLabel;
private JSpinner WeightSpinner;
private JCheckBox PipeCheckBox;
private JCheckBox FuelCheckBox;
private JLabel SimpleObjectLabel;
private JLabel AdvancedObjectLabel;
private JLabel SimpleWheelsLabel;
private JLabel StarWheelsLabel;
private JLabel RoundWheelsLabel;
private JSpinner WheelsCountSpinner;
private JLabel WheelsCountLabel;
private JPanel RedColorPanel;
private JPanel GreenColorPanel;
private JPanel BlueColorPanel;
private JPanel YellowColorPanel;
private JPanel WhiteColorPanel;
private JPanel BlackColorPanel;
private JPanel AquaColorPanel;
private JPanel PurpleColorPanel;
private JLabel MainColorLabel;
private JLabel ExtraColorLabel;
private JPanel ObjectViewPanel;
private JButton AddButton;
private JButton CancelButton;
public FormLocomotiveConfig() {
// Добавили цветные границы
SimpleObjectLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
AdvancedObjectLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
SimpleWheelsLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
RoundWheelsLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
StarWheelsLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
MainColorLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
ExtraColorLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
setContentPane(FormPanel);
setSize(800, 500);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}
}