From 00465b2d74dfdba4a6ace81e1f5739ec65ee3bbf Mon Sep 17 00:00:00 2001 From: ekallin Date: Mon, 4 Dec 2023 17:29:37 +0400 Subject: [PATCH] ready lab 5 yeea --- .../FormLocomotiveCollections.form | 6 ++--- .../FormLocomotiveCollections.java | 22 ++++--------------- .../FormLocomotiveConfig.java | 16 +------------- .../FrameLocomotiveConfig.java | 1 + 4 files changed, 9 insertions(+), 36 deletions(-) diff --git a/ProjectElectricLocomotive/FormLocomotiveCollections.form b/ProjectElectricLocomotive/FormLocomotiveCollections.form index c0478f4..a479986 100644 --- a/ProjectElectricLocomotive/FormLocomotiveCollections.form +++ b/ProjectElectricLocomotive/FormLocomotiveCollections.form @@ -12,9 +12,9 @@ - - - + + + diff --git a/ProjectElectricLocomotive/FormLocomotiveCollections.java b/ProjectElectricLocomotive/FormLocomotiveCollections.java index 50afffe..7cee3a7 100644 --- a/ProjectElectricLocomotive/FormLocomotiveCollections.java +++ b/ProjectElectricLocomotive/FormLocomotiveCollections.java @@ -35,7 +35,7 @@ public class FormLocomotiveCollections { public FormLocomotiveCollections() { formElectricLocomotive = new FormElectricLocomotive(); formLocomotiveConfig = new FormLocomotiveConfig(); - _storage = new LocomotivesGenericStorage(400,300); + _storage = new LocomotivesGenericStorage(pictureBoxCollections.getWidth(), pictureBoxCollections.getHeight()); _stackRemoveObjects = new Stack<>(); listBoxStorage.addListSelectionListener(this::listBoxObjectsSelectedIndexChanged); @@ -84,25 +84,11 @@ public class FormLocomotiveCollections { JOptionPane.showMessageDialog(getPictureBoxCollections(), "Не удалось добавить объект"); } } - - //loco = frameLocomotiveConfig._formLocomotiveConfig. }); -//12 FrameElectricLocomotive frameElectricLocomotive = new FrameElectricLocomotive(); -// frameElectricLocomotive.setVisible(true); -// frameElectricLocomotive._formElectricLocomotive.ButtonSelectLocomotive.addActionListener(e2 -> { -// loco = frameElectricLocomotive._formElectricLocomotive._drawingLocomotive; -// frameElectricLocomotive.dispose(); -// if (loco != null) { -// //проверяем, удалось ли нам загрузить объект -// if (obj.AddOverload(loco)!= -1) { -// JOptionPane.showMessageDialog(getPictureBoxCollections(), "Объект добавлен"); -// Refresh(); -// } else { -// JOptionPane.showMessageDialog(getPictureBoxCollections(), "Не удалось добавить объект"); -// } -// } -// }); + frameLocomotiveConfig._formLocomotiveConfig.buttonClose.addActionListener(e3 -> { + frameLocomotiveConfig.dispose(); + }); }); ButtonCreateRandomLoco.addActionListener(e -> { diff --git a/ProjectElectricLocomotive/FormLocomotiveConfig.java b/ProjectElectricLocomotive/FormLocomotiveConfig.java index cef832c..b6b8fdb 100644 --- a/ProjectElectricLocomotive/FormLocomotiveConfig.java +++ b/ProjectElectricLocomotive/FormLocomotiveConfig.java @@ -29,7 +29,7 @@ public class FormLocomotiveConfig{ public JLabel lableSimpleObject; private JLabel labelModifiedObject; public JButton buttonOk; - private JButton buttonClose; + public JButton buttonClose; private JLabel labelColor; private JLabel labelDopColor; public JComponent pictureBoxObject; @@ -191,8 +191,6 @@ public class FormLocomotiveConfig{ } } - - public FormLocomotiveConfig() { Border br = BorderFactory.createLineBorder(Color.BLACK); @@ -262,7 +260,6 @@ public class FormLocomotiveConfig{ } return false; } - } ); @@ -358,17 +355,6 @@ public class FormLocomotiveConfig{ } } ); - buttonClose.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - frameLocomotiveConfig.dispose(); - } - } - ); - } - - public void Draw() { - pictureBoxObject.repaint(); } private void createUIComponents(){ diff --git a/ProjectElectricLocomotive/FrameLocomotiveConfig.java b/ProjectElectricLocomotive/FrameLocomotiveConfig.java index 0944dc6..d769a4c 100644 --- a/ProjectElectricLocomotive/FrameLocomotiveConfig.java +++ b/ProjectElectricLocomotive/FrameLocomotiveConfig.java @@ -19,4 +19,5 @@ public class FrameLocomotiveConfig extends JFrame{ pack(); setVisible(true); } + }