Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lab7;
- import java.awt.BorderLayout;
- import java.awt.Dimension;
- import java.awt.GridLayout;
- import java.sql.SQLException;
- import javax.swing.*;
- @SuppressWarnings("serial")
- public class Window extends JFrame
- {
- private JToolBar navToolBar;
- private JPanel center;
- private JButton next;
- private JButton previous;
- private JButton first;
- private JButton last;
- private JButton add;
- private JButton remove;
- private JButton save;
- private JButton edit;
- private JButton search;
- private JButton cancel;
- private JTextField current;
- private JTextField idField;
- private JTextField nameField;
- private JTextField ageField;
- private JLabel idLabel;
- private JLabel nameLabel;
- private JLabel ageLabel;
- private Controller personController;
- public Window() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
- {
- super("Evidenta persoane");
- this.setSize(500, 300);
- this.setDefaultCloseOperation(EXIT_ON_CLOSE);
- this.setLayout(new BorderLayout());
- this.navToolBar = new JToolBar();
- this.first = new JButton();
- this.first.setIcon(new ImageIcon("Imagini/MoveFirst.png"));
- this.first.setName("first");
- this.previous = new JButton();
- this.previous.setIcon(new ImageIcon("Imagini/MovePrevious.png"));
- this.previous.setName("previous");
- this.next = new JButton();
- this.next.setIcon(new ImageIcon("Imagini/MoveNext.png"));
- this.next.setName("next");
- this.last = new JButton();
- this.last.setIcon(new ImageIcon("Imagini/MoveLast.png"));
- this.last.setName("last");
- this.add = new JButton();
- this.add.setIcon(new ImageIcon("Imagini/Add.png"));
- this.add.setName("add");
- this.edit = new JButton();
- this.edit.setIcon(new ImageIcon("Imagini/Edit.png"));
- this.edit.setName("edit");
- this.remove = new JButton();
- this.remove.setIcon(new ImageIcon("Imagini/Delete.png"));
- this.remove.setName("remove")
- ;
- this.search = new JButton();
- this.search.setIcon(new ImageIcon("Imagini/find.jpg"));
- this.search.setName("search");
- this.save = new JButton();
- this.save.setIcon(new ImageIcon("Imagini/save.jpg"));
- this.save.setName("save");
- this.cancel = new JButton();
- this.cancel.setIcon(new ImageIcon("Imagini/undo.jpg"));
- this.cancel.setName("cancel");
- this.current = new JTextField();
- this.current.setEditable(false);
- this.navToolBar.add(first);
- this.navToolBar.add(previous);
- this.navToolBar.add(current);
- this.navToolBar.add(next);
- this.navToolBar.add(last);
- this.navToolBar.add(add);
- this.navToolBar.add(edit);
- this.navToolBar.add(remove);
- this.navToolBar.add(search);
- this.navToolBar.add(save);
- this.navToolBar.add(cancel);
- this.getContentPane().add(navToolBar, BorderLayout.NORTH);
- this.center = new JPanel();
- this.center.setLayout(new GridLayout(3, 2));
- this.center.setPreferredSize(new Dimension(60, 40));
- this.idLabel = new JLabel();
- this.idLabel.setText("ID");
- this.nameLabel = new JLabel();
- this.nameLabel.setText("Nume");
- this.ageLabel = new JLabel();
- this.ageLabel.setText("Varsta");
- this.idField = new JTextField();
- this.nameField = new JTextField();
- this.ageField = new JTextField();
- this.center.add(idLabel);
- this.center.add(idField);
- this.center.add(nameLabel);
- this.center.add(nameField);
- this.center.add(ageLabel);
- this.center.add(ageField);
- this.personController = new Controller(this.current, this.idField, this.nameField,
- this.ageField, this.next, this.previous, this.first, this.last, this.add,
- this.remove, this.save, this.edit, this.search, this.cancel);
- this.personController.initialise();
- this.next.addActionListener(personController);
- this.previous.addActionListener(personController);
- this.first.addActionListener(personController);
- this.last.addActionListener(personController);
- this.search.addActionListener(personController);
- this.remove.addActionListener(personController);
- this.edit.addActionListener(personController);
- this.add.addActionListener(personController);
- this.cancel.addActionListener(personController);
- this.save.addActionListener(personController);
- this.getContentPane().add(center, BorderLayout.CENTER);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement