Components & Properties
Java graphical elements are based on the Composite design pattern and are divided into "basic" components (Button, Label, TextField, etc.) and "composite" (Frame or Panel for instance) with fundamentaly an "add" operation to add recursively other basic/composite components.
Each component is characterized by "properties" specified with getter/setter (and have to be distinguished with attributes).
JFrame frame = new JFrame("Demo1");
JPanel panel = new JPanel();
JLabel label = new JLabel("Your name:");
JTextField name = new JTextField(10);
JButton button = new JButton("Validate");
panel.add(label);
panel.add(name);
frame.add(panel);
frame.add(button);
frame.setLayout(new GridLayout(2,1));
frame.pack();
frame.setVisible(true);
source
As an exercise, draw the tree structure of the User Interface (UI) by the way of an objects' diagram.
2 - 12Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented
Java jva jav laurent thiry uha enseignant ensisa ecole school national alsace programmation objet approche mulhouse france java object programming oriented