And implement one view properly.
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
private List<String> colorList = Arrays.asList("black", "green", "blue", "brown");
/**
- *
* @param color
*/
Eye(String color) {
}
/**
- *
* @return
*/
public Color getColor() {
}
/**
- *
* @param color
*/
public void setColor(String color) {
}
/**
- *
* @param color
* @return
*/
}
/**
- *
* @param eye
* @return
*/
-public class EyeView {
+import javax.swing.*;
+
+public class EyeView extends JComponent {
private Eye eyeObj;
+ EyeView() {
+ }
+
/**
- *
* @param eyeObj
*/
EyeView(Eye eyeObj) {
}
/**
- *
* @return
*/
public Eye getEyeObj() {
}
/**
- *
* @param eyeObj
*/
public void setEyeObj(Eye eyeObj) {
-public class FirstnameView {
+import javax.swing.*;
+
+public class FirstnameView extends JComponent {
private Firstname firstnameObj;
+ private JTextField textField;
+ private JLabel label;
- FirstnameView(Firstname firstnameObj) {
- setFirstnameObj(firstnameObj);
+ FirstnameView(int length) {
+ this.label = new JLabel();
+ this.label.setText("Firstname");
+ this.textField = new JTextField(length);
+ add(label);
+ add(textField);
}
public Firstname getFirstnameObj() {
public class LevenshteinDistance {
/**
- *
* @param a
* @param b
* @param c
}
/**
- *
* @param lhs
* @param rhs
* @return
import javax.swing.*;
+import java.awt.*;
+import java.util.ArrayList;
public class MainWindowsView extends JFrame {
MainWindowsView(String title) {
//Create and set up the window.
setTitle(title);
+ setSize(300, 300);
+ setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new PersonView();
- //TODO: Add content to the panel
- //JLabel label = new JLabel("Hello World");
- //panel.add(label);
+ //Get all Swing/AWT primitive components in the views and add them to the panel.
+ ArrayList<Component> components = new ArrayList<>();
+ for (int i = 0; i < panel.getComponentCount(); i++) {
+ if ((panel.getComponent(i) instanceof Container)) {
+ Container subContainer = (Container) panel.getComponent(i);
+ for (int j = 0; j < subContainer.getComponentCount(); j++) {
+ components.add(subContainer.getComponent(j));
+ }
+ }
+ }
+ for (Component component : components) {
+ panel.add(component);
+ }
- getContentPane().add(panel);
+ setContentPane(panel);
}
/**
public void showGUI() {
//Display the window.
- this.pack();
+ //this.pack();
this.setVisible(true);
}
-public class OriginView {
+import javax.swing.*;
+
+public class OriginView extends JComponent {
private Origin originObj;
+ OriginView() {
+ }
+
OriginView(Origin originObj) {
setOriginObj(originObj);
}
private EyeView eyeView;
PersonView() {
+ setFirstnameView(new FirstnameView(10));
+ setOriginView(new OriginView());
+ setSizeView(new SizeView());
+ setWeightView(new WeightView());
+ setEyeView(new EyeView());
+ add(firstnameView);
+ add(originView);
+ add(sizeView);
+ add(weightView);
+ add(eyeView);
}
PersonView(FirstnameView firstnameView, OriginView originView, SizeView sizeView, WeightView weightView, EyeView eyeView) {
}
/**
- *
* @return
*/
public FirstnameView getFirstnameView() {
}
/**
- *
* @param firstnameView
*/
public void setFirstnameView(FirstnameView firstnameView) {
}
/**
- *
* @return
*/
public OriginView getOriginView() {
}
/**
- *
* @param originView
*/
public void setOriginView(OriginView originView) {
}
/**
- *
* @return
*/
public SizeView getSizeView() {
}
/**
- *
* @param sizeView
*/
public void setSizeView(SizeView sizeView) {
}
/**
- *
* @return
*/
public WeightView getWeightView() {
}
/**
- *
* @param weightView
*/
public void setWeightView(WeightView weightView) {
}
/**
- *
* @param eyeView
*/
public void setEyeView(EyeView eyeView) {
}
/**
- *
* @return
*/
public EyeView getEyeView() {
-public class SizeView {
+import javax.swing.*;
+
+public class SizeView extends JComponent {
private Size sizeObj;
+ SizeView() {
+ }
+
SizeView(Size sizeObj) {
setSizeObj(sizeObj);
}
-public class WeightView {
+import javax.swing.*;
+
+public class WeightView extends JComponent {
private Weight weightObj;
+ WeightView() {
+ }
+
WeightView(Weight weightObj) {
setWeightObj(weightObj);
}