From d119e60d58d8431de3ff29090d7048b0eb7d9f9e Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 11 Jan 2019 16:12:36 +0100 Subject: [PATCH] Put each view inside its own panel and add each panel to the main panel. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/EyeView.java | 5 ++--- src/FirstnameView.java | 2 +- src/Main.java | 3 ++- src/MainWindowsView.java | 2 +- src/OriginView.java | 2 +- src/SizeView.java | 2 +- src/WeightView.java | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/EyeView.java b/src/EyeView.java index f976a4e..a80a31a 100644 --- a/src/EyeView.java +++ b/src/EyeView.java @@ -1,6 +1,6 @@ import javax.swing.*; -public class EyeView extends JComponent { +public class EyeView extends JPanel { private Eye eyeObj; private JLabel label; private JComboBox colorsList; @@ -13,8 +13,7 @@ public class EyeView extends JComponent { this.label = new JLabel(); this.label.setText("Eyes color"); this.colorsList = new JComboBox<>(this.getEyeObj().getColorsList()); - if (this.getEyeObj().getStrColor() != null) - this.colorsList.setSelectedItem(this.getEyeObj().getStrColor()); + this.colorsList.setSelectedItem(this.getEyeObj().getStrColor()); add(label); add(colorsList); } diff --git a/src/FirstnameView.java b/src/FirstnameView.java index 8634dc7..b7b8568 100644 --- a/src/FirstnameView.java +++ b/src/FirstnameView.java @@ -1,6 +1,6 @@ import javax.swing.*; -public class FirstnameView extends JComponent { +public class FirstnameView extends JPanel { private Firstname firstnameObj; private JTextField textField; private JLabel label; diff --git a/src/Main.java b/src/Main.java index 5bac73e..361c00e 100644 --- a/src/Main.java +++ b/src/Main.java @@ -17,7 +17,8 @@ public class Main { Person person4 = new Person("Sophia", "Brasil", 155, 57, "blue"); personArrayList.add(person4); - Person emptyPerson = new Person(); + //Person emptyPerson = new Person(); + Person emptyPerson = person2; emptyPerson.setPersonArrayList(personArrayList); PersonView emptyPersonView = new PersonView(emptyPerson); diff --git a/src/MainWindowsView.java b/src/MainWindowsView.java index dbe2eed..c3688ba 100644 --- a/src/MainWindowsView.java +++ b/src/MainWindowsView.java @@ -26,7 +26,7 @@ public class MainWindowsView extends JFrame { }); fileMenu.add(exit); - //Get all Swing/AWT primitive components in the views and add them to the panel. + //Get all Swing/AWT primitive components in the views and add them to the main panel. ArrayList components = new ArrayList<>(); for (int i = 0; i < panel.getComponentCount(); i++) { if ((panel.getComponent(i) instanceof Container)) { diff --git a/src/OriginView.java b/src/OriginView.java index 695a90c..3c3b518 100644 --- a/src/OriginView.java +++ b/src/OriginView.java @@ -1,6 +1,6 @@ import javax.swing.*; -public class OriginView extends JComponent { +public class OriginView extends JPanel { private Origin originObj; private JLabel label; diff --git a/src/SizeView.java b/src/SizeView.java index 18e5016..0173615 100644 --- a/src/SizeView.java +++ b/src/SizeView.java @@ -1,6 +1,6 @@ import javax.swing.*; -public class SizeView extends JComponent { +public class SizeView extends JPanel { private Size sizeObj; private JLabel label; diff --git a/src/WeightView.java b/src/WeightView.java index 1576b62..9e7ef20 100644 --- a/src/WeightView.java +++ b/src/WeightView.java @@ -1,6 +1,6 @@ import javax.swing.*; -public class WeightView extends JComponent { +public class WeightView extends JPanel { private Weight weightObj; private JLabel label; -- 2.34.1