package personFiles;
import java.awt.*;
import java.util.List;
import java.awt.event.*;
import java.util.ArrayList;
import javax.swing.*;
import javax.swing.event.*;
@SuppressWarnings({ "serial", "unchecked" })
public class Osoblje extends JFrame {
private JList outputJTA = new JList();
private JScrollPane outputJTAScrollPane = new JScrollPane(outputJTA);
private JLabel idJL = new JLabel();
private JLabel nameJL = new JLabel();
private JTextField idJTF = new JTextField();
private JTextField nameJTF = new JTextField();
private JLabel surnameJL = new JLabel();
private JLabel ageJL = new JLabel();
private JTextField surnameJTF = new JTextField();
private JTextField ageJTF = new JTextField();
private JLabel genderJL = new JLabel();
private JTextField genderJTF = new JTextField();
private JButton newPersonJB = new JButton();
private JButton pokaziJB = new JButton();
List<Person> personList = new ArrayList<>();
public Osoblje(String title) {
// Frame-Initialisierung
super(title);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
int frameWidth = 310;
int frameHeight = 269;
setSize(frameWidth, frameHeight);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
int x = (d.width - getSize().width) / 2;
int y = (d.height - getSize().height) / 2;
setLocation(x, y);
setResizable(false);
Container cp = getContentPane();
cp.setLayout(null);
// Anfang Komponenten
outputJTAScrollPane.setBounds(8, 8, 129, 217);
cp.add(outputJTAScrollPane);
idJL.setBounds(152, 16, 51, 19);
idJL.setText("ID:");
cp.add(idJL);
nameJL.setBounds(152, 40, 54, 20);
nameJL.setText("Name:");
cp.add(nameJL);
idJTF.setBounds(208, 16, 65, 17);
cp.add(idJTF);
nameJTF.setBounds(208, 40, 65, 17);
cp.add(nameJTF);
surnameJL.setBounds(152, 64, 59, 19);
surnameJL.setText("Surname:");
cp.add(surnameJL);
ageJL.setBounds(152, 88, 51, 19);
ageJL.setText("Age:");
cp.add(ageJL);
surnameJTF.setBounds(208, 64, 65, 17);
cp.add(surnameJTF);
ageJTF.setBounds(208, 88, 65, 17);
cp.add(ageJTF);
genderJL.setBounds(152, 112, 59, 19);
genderJL.setText("Gender:");
cp.add(genderJL);
genderJTF.setBounds(208, 112, 65, 17);
cp.add(genderJTF);
newPersonJB.setBounds(152, 144, 121, 25);
newPersonJB.setText("nova osoba");
newPersonJB.setMargin(new Insets(2, 2, 2, 2));
newPersonJB.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
newPersonJB_ActionPerformed(evt);
}
});
cp.add(newPersonJB);
pokaziJB.setBounds(152, 184, 121, 25);
pokaziJB.setText("pokazi");
pokaziJB.setMargin(new Insets(2, 2, 2, 2));
pokaziJB.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
pokaziJB_ActionPerformed(evt);
}
});
cp.add(pokaziJB);
// Ende Komponenten
setVisible(true);
} // end of public Osoblje
// Anfang Methoden
public static void main(String[] args) {
new Osoblje("Osoblje");
} // end of main
public void newPersonJB_ActionPerformed(ActionEvent evt) {
personList.add(new Person(idJTF.getText(), nameJTF.getText(), surnameJTF.getText(), ageJTF.getText(), genderJTF.getText()));//create new person
} // end of newPersonJB_ActionPerformed
public void pokaziJB_ActionPerformed(ActionEvent evt) {
outputJTA.setText(personList + "\n"); //display personList
} // end of pokaziJB_ActionPerformed
}