Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cartedetelefon.GUI;
- import cartedetelefon.CarteDeTelefon;
- import cartedetelefon.NrTel;
- import java.awt.Component;
- import java.awt.HeadlessException;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.io.File;
- import java.io.FileFilter;
- import java.io.IOException;
- import java.net.URL;
- import java.text.SimpleDateFormat;
- import java.util.Arrays;
- import java.util.Calendar;
- import java.util.GregorianCalendar;
- import java.util.List;
- import java.util.Timer;
- import java.util.TimerTask;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import javax.swing.ImageIcon;
- import javax.swing.JFileChooser;
- import javax.swing.JOptionPane;
- import javax.swing.table.TableRowSorter;
- public class GUI extends javax.swing.JFrame {
- private static final long serialVersionUID = 1L;
- private List<File> poze;
- private Timer timer1 = new Timer();
- CarteDeTelefon model = new CarteDeTelefon();
- @SuppressWarnings("unchecked")
- TableRowSorter sorter = new TableRowSorter(model);
- /**
- * Creates new form GUI
- */
- @SuppressWarnings({"unchecked", "unchecked"})
- public GUI() {
- initComponents();
- jTable.setModel(model);
- try {
- jTable.setRowSorter(new TableRowSorter(model));
- } catch (Exception e) {
- }
- jTable.setRowSorter(sorter);
- open.setEnabled(false);
- save.setEnabled(false);
- javax.swing.Timer timer2 = new javax.swing.Timer(1000, new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent ae) {
- }
- });
- timer2.start();
- TimerTask task = new TimerTask() {
- @Override
- public void run() {
- displayBanner();
- }
- };
- timer1.schedule(task, 1000, 4000);
- }
- /**
- * This method is called from within the constructor to initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is always
- * regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- jScrollPane2 = new javax.swing.JScrollPane();
- jTable = new javax.swing.JTable();
- tfNume = new javax.swing.JTextField();
- jLabel1 = new javax.swing.JLabel();
- jLabel2 = new javax.swing.JLabel();
- tfPrenume = new javax.swing.JTextField();
- jLabel3 = new javax.swing.JLabel();
- tfCNP = new javax.swing.JTextField();
- jLabel4 = new javax.swing.JLabel();
- tfTel = new javax.swing.JTextField();
- adauga = new javax.swing.JButton();
- tfFilter = new javax.swing.JTextField();
- cauta = new javax.swing.JButton();
- iesire = new javax.swing.JButton();
- sterge = new javax.swing.JButton();
- modifica = new javax.swing.JButton();
- jBan = new javax.swing.JLabel();
- jMenuBar1 = new javax.swing.JMenuBar();
- jMenu1 = new javax.swing.JMenu();
- open = new javax.swing.JMenuItem();
- save = new javax.swing.JMenuItem();
- jSeparator1 = new javax.swing.JPopupMenu.Separator();
- iesireM = new javax.swing.JMenuItem();
- jMenu2 = new javax.swing.JMenu();
- adaugaM = new javax.swing.JMenuItem();
- cautaM = new javax.swing.JMenuItem();
- modificaM = new javax.swing.JMenuItem();
- stergeM = new javax.swing.JMenuItem();
- jMenu3 = new javax.swing.JMenu();
- inregistrare = new javax.swing.JMenuItem();
- jSeparator2 = new javax.swing.JPopupMenu.Separator();
- about = new javax.swing.JMenuItem();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- jTable.setModel(new javax.swing.table.DefaultTableModel(
- new Object [][] {
- {null, null, null, null},
- {null, null, null, null},
- {null, null, null, null},
- {null, null, null, null}
- },
- new String [] {
- "Title 1", "Title 2", "Title 3", "Title 4"
- }
- ));
- jScrollPane2.setViewportView(jTable);
- jLabel1.setText("Nume");
- jLabel2.setText("Prenume");
- jLabel3.setText("CNP");
- jLabel4.setText("Telefon");
- adauga.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
- adauga.setMnemonic('A');
- adauga.setText("Adauga");
- adauga.setToolTipText("Adauga un contact nou");
- adauga.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- adaugaActionPerformed(evt);
- }
- });
- tfFilter.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- tfFilterActionPerformed(evt);
- }
- });
- cauta.setMnemonic('c');
- cauta.setText("Cauta");
- cauta.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mouseClicked(java.awt.event.MouseEvent evt) {
- cautaMouseClicked(evt);
- }
- });
- cauta.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- cautaActionPerformed(evt);
- }
- });
- iesire.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
- iesire.setForeground(new java.awt.Color(255, 0, 0));
- iesire.setText("Iesire");
- iesire.setToolTipText("Inchide aplicatie");
- iesire.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- iesireActionPerformed(evt);
- }
- });
- sterge.setMnemonic('q');
- sterge.setText("Sterge");
- sterge.setToolTipText("Sterge contact");
- sterge.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
- sterge.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- stergeActionPerformed(evt);
- }
- });
- modifica.setMnemonic('m');
- modifica.setText("Modifica");
- modifica.setToolTipText("Modifica numar telefon");
- modifica.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- modificaActionPerformed(evt);
- }
- });
- jBan.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
- jMenu1.setMnemonic('f');
- jMenu1.setText("File");
- open.setMnemonic('o');
- open.setText("Open");
- open.setToolTipText("Deschide fiser contacte");
- open.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- openActionPerformed(evt);
- }
- });
- jMenu1.add(open);
- save.setMnemonic('s');
- save.setText("Save");
- save.setToolTipText("Salveaza contactele");
- save.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- saveActionPerformed(evt);
- }
- });
- jMenu1.add(save);
- jMenu1.add(jSeparator1);
- iesireM.setMnemonic('i');
- iesireM.setText("Iesire");
- iesireM.setToolTipText("Inchide aplicatia");
- iesireM.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- iesireMActionPerformed(evt);
- }
- });
- jMenu1.add(iesireM);
- jMenuBar1.add(jMenu1);
- jMenu2.setText("Abonati");
- adaugaM.setMnemonic('a');
- adaugaM.setText("Adauga");
- adaugaM.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- adaugaMActionPerformed(evt);
- }
- });
- jMenu2.add(adaugaM);
- cautaM.setMnemonic('c');
- cautaM.setText("Cauta");
- cautaM.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- cautaMActionPerformed(evt);
- }
- });
- jMenu2.add(cautaM);
- modificaM.setMnemonic('m');
- modificaM.setText("Modifica");
- modificaM.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- modificaMActionPerformed(evt);
- }
- });
- jMenu2.add(modificaM);
- stergeM.setMnemonic('q');
- stergeM.setText("Sterge");
- stergeM.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- stergeMActionPerformed(evt);
- }
- });
- jMenu2.add(stergeM);
- jMenuBar1.add(jMenu2);
- jMenu3.setMnemonic('h');
- jMenu3.setText("Help");
- inregistrare.setText("Inregistrare");
- inregistrare.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- inregistrareActionPerformed(evt);
- }
- });
- jMenu3.add(inregistrare);
- jMenu3.add(jSeparator2);
- about.setText("About");
- about.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- aboutActionPerformed(evt);
- }
- });
- jMenu3.add(about);
- jMenuBar1.add(jMenu3);
- setJMenuBar(jMenuBar1);
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
- .addComponent(jScrollPane2)
- .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
- .addComponent(tfFilter, javax.swing.GroupLayout.PREFERRED_SIZE, 236, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(cauta, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(sterge, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(modifica, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(iesire, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
- .addComponent(jLabel1)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(tfNume, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jLabel2)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(tfPrenume, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jLabel3)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(tfCNP, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jLabel4)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(tfTel, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(18, 18, 18)
- .addComponent(adauga, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addComponent(jBan, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addContainerGap(19, Short.MAX_VALUE))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel1)
- .addComponent(tfNume, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel2)
- .addComponent(tfPrenume, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel3)
- .addComponent(tfCNP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel4)
- .addComponent(tfTel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(adauga))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 397, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(27, 27, 27)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(tfFilter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(cauta)
- .addComponent(sterge)
- .addComponent(modifica)
- .addComponent(iesire))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jBan, javax.swing.GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE)
- .addContainerGap())
- );
- pack();
- }// </editor-fold>
- private void adaugaActionPerformed(java.awt.event.ActionEvent evt) {
- try {
- String nume = tfNume.getText();
- String prenume = tfPrenume.getText();
- String cnp = tfCNP.getText();
- String nrtel = tfTel.getText();
- for (int i = 0; i < jTable.getRowCount(); ++i) {
- if (cnp.equals(jTable.getValueAt(i, 2))) {
- JOptionPane.showMessageDialog(this, "CNP deja utilizat.", "Eroare", JOptionPane.ERROR_MESSAGE);
- return;
- }
- if (nrtel.equals(jTable.getValueAt(i, 3).toString())) {
- JOptionPane.showMessageDialog(this, "Numar telefon deja utilizat", "Eroare", JOptionPane.ERROR_MESSAGE);
- return;
- }
- }
- model.adaugareContact(nume, prenume, cnp, nrtel);
- tfNume.setText("");
- tfPrenume.setText("");
- tfCNP.setText("");
- tfTel.setText("");
- } catch (HeadlessException e) {
- }
- }
- private void openActionPerformed(java.awt.event.ActionEvent evt) {
- try {
- final JFileChooser fc = new JFileChooser();
- if (evt.getSource() == open) {
- int returnVal = fc.showOpenDialog(GUI.this);
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- try {
- try {
- model.incarcareContacte();
- } catch (ClassNotFoundException ex) {
- Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
- }
- } catch (IOException ex) {
- Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }
- } catch (HeadlessException headlessException) {
- }
- }
- private void cautaMActionPerformed(java.awt.event.ActionEvent evt) {
- try {
- if (model.getRowCount() > 0) {
- for (int i = 0; i < model.getRowCount(); i++) {
- if (tfFilter.getText().equalsIgnoreCase((String) model.getValueAt(i, 0))) {
- jTable.setRowSelectionInterval(i, i);
- } else if (tfFilter.getText().equalsIgnoreCase((String) model.getValueAt(i, 1))) {
- jTable.setRowSelectionInterval(i, i);
- } else if (tfFilter.getText().equals(model.getValueAt(i, 2))) {
- jTable.setRowSelectionInterval(i, i);
- } else if (tfFilter.getText().equals(model.getValueAt(i, 3).toString())) {
- jTable.setRowSelectionInterval(i, i);
- }
- }
- }
- } catch (Exception e) {
- }
- }
- private void stergeMActionPerformed(java.awt.event.ActionEvent evt) {
- try {
- int selRow = jTable.getSelectedRow();
- if (selRow != -1) {
- model.stergeContact(selRow);
- }
- tfNume.setText("");
- tfPrenume.setText("");
- tfCNP.setText("");
- tfTel.setText("");
- } catch (Exception e) {
- }
- }
- private void iesireMActionPerformed(java.awt.event.ActionEvent evt) {
- System.exit(0);
- }
- private void saveActionPerformed(java.awt.event.ActionEvent evt) {
- try {
- model.salvareContacte();
- } catch (IOException ex) {
- Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- private void aboutActionPerformed(java.awt.event.ActionEvent evt) {
- try {
- Component frame = null;
- JOptionPane.showMessageDialog(frame, "Agenda telefonica v1.1");
- } catch (HeadlessException headlessException) {
- }
- }
- private void adaugaMActionPerformed(java.awt.event.ActionEvent evt) {
- try {
- String nume = tfNume.getText();
- String prenume = tfPrenume.getText();
- String cnp = tfCNP.getText();
- String nrtel = tfTel.getText();
- for (int i = 0; i < jTable.getRowCount(); ++i) {
- if (cnp.equals(jTable.getValueAt(i, 2))) {
- JOptionPane.showMessageDialog(this, "CNP deja utilizat.", "Eroare", JOptionPane.ERROR_MESSAGE);
- return;
- }
- if (nrtel.equals(jTable.getValueAt(i, 3).toString())) {
- JOptionPane.showMessageDialog(this, "Numar telefon deja utilizat", "Eroare", JOptionPane.ERROR_MESSAGE);
- return;
- }
- }
- model.adaugareContact(nume, prenume, cnp, nrtel);
- tfNume.setText("");
- tfPrenume.setText("");
- tfCNP.setText("");
- tfTel.setText("");
- } catch (HeadlessException e) {
- }
- }
- private void stergeActionPerformed(java.awt.event.ActionEvent evt) {
- try {
- int selRow = jTable.getSelectedRow();
- if (selRow != -1) {
- model.stergeContact(selRow);
- }
- tfNume.setText("");
- tfPrenume.setText("");
- tfCNP.setText("");
- tfTel.setText("");
- } catch (Exception e) {
- }
- }
- private void modificaActionPerformed(java.awt.event.ActionEvent evt) {
- try {
- String cnp = JOptionPane.showInputDialog("Modifica CNP");
- model.setValueAt(cnp, jTable.getSelectedRow(), 2);
- String tel = JOptionPane.showInputDialog("Modifica numarul de telefon");
- NrTel nrtel = new NrTel(Integer.parseInt(tel));
- jTable.getModel().setValueAt(nrtel, 0, 3);
- } catch (NumberFormatException numberFormatException) {
- }
- }
- private void iesireActionPerformed(java.awt.event.ActionEvent evt) {
- System.exit(0);
- }
- private void tfFilterActionPerformed(java.awt.event.ActionEvent evt) {
- try {
- if (model.getRowCount() > 0) {
- for (int i = 0; i < model.getRowCount(); i++) {
- if (tfFilter.getText().equalsIgnoreCase((String) model.getValueAt(i, 0))) {
- jTable.setRowSelectionInterval(i, i);
- } else if (tfFilter.getText().equalsIgnoreCase((String) model.getValueAt(i, 1))) {
- jTable.setRowSelectionInterval(i, i);
- } else if (tfFilter.getText().equals(model.getValueAt(i, 2))) {
- jTable.setRowSelectionInterval(i, i);
- } else if (tfFilter.getText().equals(model.getValueAt(i, 3).toString())) {
- jTable.setRowSelectionInterval(i, i);
- }
- }
- }
- } catch (Exception e) {
- }
- }
- private void cautaActionPerformed(java.awt.event.ActionEvent evt) {
- try {
- if (model.getRowCount() > 0) {
- for (int i = 0; i < model.getRowCount(); i++) {
- if (tfFilter.getText().equalsIgnoreCase((String) model.getValueAt(i, 0))) {
- jTable.setRowSelectionInterval(i, i);
- } else if (tfFilter.getText().equalsIgnoreCase((String) model.getValueAt(i, 1))) {
- jTable.setRowSelectionInterval(i, i);
- } else if (tfFilter.getText().equals(model.getValueAt(i, 2))) {
- jTable.setRowSelectionInterval(i, i);
- } else if (tfFilter.getText().equals(model.getValueAt(i, 3).toString())) {
- jTable.setRowSelectionInterval(i, i);
- }
- }
- }
- } catch (Exception e) {
- }
- }
- private void cautaMouseClicked(java.awt.event.MouseEvent evt) {
- }
- private void modificaMActionPerformed(java.awt.event.ActionEvent evt) {
- try {
- String cnp = JOptionPane.showInputDialog("Modifica CNP");
- model.setValueAt(cnp, jTable.getSelectedRow(), 2);
- String tel = JOptionPane.showInputDialog("Modifica numarul de telefon");
- NrTel nrtel = new NrTel(Integer.parseInt(tel));
- jTable.getModel().setValueAt(nrtel, 0, 3);
- } catch (NumberFormatException numberFormatException) {
- }
- }
- private void inregistrareActionPerformed(java.awt.event.ActionEvent evt) {
- try {
- String cheie = JOptionPane.showInputDialog(this, "Cod de inregistrare:", "Inregistrare", JOptionPane.OK_CANCEL_OPTION);
- if (!cheie.equals("titi")) {
- JOptionPane.showMessageDialog(this, "Codul este gresit!", "Eroare", JOptionPane.ERROR_MESSAGE);
- } else {
- JOptionPane.showMessageDialog(this, "Cod acceptat!", "Corect", JOptionPane.PLAIN_MESSAGE);
- timer1.cancel();
- jBan.setVisible(false);
- inregistrare.setEnabled(false);
- open.setEnabled(true);
- save.setEnabled(true);
- }
- } catch (HeadlessException headlessException) {
- }
- }
- private void displayBanner(){
- URL url = getClass().getResource("/img");
- File dir = new File(url.getPath());
- File[] fisiere = dir.listFiles(new FileFilter() {
- @Override
- public boolean accept(File f) {
- return f.getName().toLowerCase().endsWith(".jpg");
- }
- });
- poze = Arrays.<File>asList(fisiere);
- int pic = (int) (Math.random()*3);
- File f = poze.get(pic);
- ImageIcon i = new ImageIcon(f.getAbsolutePath());
- jBan.setText("");
- jBan.setIcon(i);
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(GUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- Thread.sleep(3000);
- } catch (InterruptedException ex) {
- Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
- }
- new GUI().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify
- private javax.swing.JMenuItem about;
- private javax.swing.JButton adauga;
- private javax.swing.JMenuItem adaugaM;
- private javax.swing.JButton cauta;
- private javax.swing.JMenuItem cautaM;
- private javax.swing.JButton iesire;
- private javax.swing.JMenuItem iesireM;
- private javax.swing.JMenuItem inregistrare;
- private javax.swing.JLabel jBan;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JLabel jLabel4;
- private javax.swing.JMenu jMenu1;
- private javax.swing.JMenu jMenu2;
- private javax.swing.JMenu jMenu3;
- private javax.swing.JMenuBar jMenuBar1;
- private javax.swing.JScrollPane jScrollPane2;
- private javax.swing.JPopupMenu.Separator jSeparator1;
- private javax.swing.JPopupMenu.Separator jSeparator2;
- private javax.swing.JTable jTable;
- private javax.swing.JButton modifica;
- private javax.swing.JMenuItem modificaM;
- private javax.swing.JMenuItem open;
- private javax.swing.JMenuItem save;
- private javax.swing.JButton sterge;
- private javax.swing.JMenuItem stergeM;
- private javax.swing.JTextField tfCNP;
- private javax.swing.JTextField tfFilter;
- private javax.swing.JTextField tfNume;
- private javax.swing.JTextField tfPrenume;
- private javax.swing.JTextField tfTel;
- // End of variables declaration
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement