Results 1 to 5 of 5
  1. #1
    Pro Alinio is offline Member
    Join Date
    Mar 2009
    Posts
    3
    Rep Power
    0

    Unhappy How could I search elements in a Jlist?Please Help!

    Hello!This is my first Thread which I post on this forum! I hAVE TO DO A PhoneBook!I am working in Nettbeens, and I don't know how to implement a method that search the elements from a Jlist.For example ,let'supose that I want to see the all person who are named "Jhon" from my list, or I want to find out that phone numbers which starts with "0734". I want to type my input dates , like " Jhon" or "0743" in a textfield and then press a "searchbutton" which should perform the searching action, and the search 's results to be display in a textarea!!!! Please Help me!

    My deepest apreciation!

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Have you tried to get the ListModel out of the JList, use a for loop to iterate through and extract each object in the model with getElementAt(int index)?

    Look at the top of the JList API and it shows you how to do exactly this.

  3. #3
    Pro Alinio is offline Member
    Join Date
    Mar 2009
    Posts
    3
    Rep Power
    0

    Default

    For this project I use 4 classes which I named:Abonat(this mean "Client" , I am from Romania, and I gave to these classes Romanian'names),The code which I've written until then is the following: "package proiect;

    import java.io.Serializable;
    import javax.swing.JOptionPane;

    /**
    *
    * @author Alinio
    */
    public class Abonat implements Serializable{
    private String nume;
    private String prenume;
    private String CNP;
    private NrTel numartelefon;




    Abonat(String nume, String prenume, String CNP, NrTel numartelefon) {

    if(nume.matches("[A-Z][a-z]{1,20}"))
    this.nume=nume;
    else throw new IllegalArgumentException("Format inavalid!Numele trebuie sa inceapa cu litera mare si contine numai litere");
    if(prenume.matches("[A-Z][a-z]{1,20}"))
    this.prenume=prenume;
    else throw new IllegalArgumentException("Format invalid!Asigurativa ca prima litera din cuvant este litera mare!");
    if(CNP.matches("[12]\\d{12}"))
    this.CNP=CNP;

    else
    throw new IllegalArgumentException("Format invalid!CNP-ul trebuie sa inceapa cu cifra 1 sau 2, iar apoi mai introduceti 12 cifre!");


    this.numartelefon=numartelefon;



    }
    @Override
    public String toString() {
    return nume + " " + prenume + " " + CNP + " " +numartelefon;
    }

    public String getNume(){
    return nume;
    }


    public String getPrenume(){
    return prenume;
    }


    public String getCnp(){
    return CNP;
    }


    public String getNrtel(){
    return numartelefon.toString();
    }

    } " ;
    NrTel(this class contain the phone number format), and has the following code : "/*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */

    package proiect;

    import java.io.Serializable;

    /**
    *
    * @author Alinio
    */
    public class NrTel implements Serializable{
    private String formatNrTelFix="";
    private String formatNrTelMobil="";

    public NrTel(String nr){
    /*if(nr.matches("[0][7][2-6]\\d{7}"))

    formatNrTelMobil=nr;
    else*/ if (nr.matches("[0][23]\\d{8}"))
    formatNrTelFix=nr;
    /* else throw new IllegalArgumentException("Formatul " +
    "numarului de telefon este invalid!!!, " +
    "un format valid este :07[2-6]xxxxxxx sau " +
    "0[23]xxxxxxx");
    //else throw new IllegalArgumentException("format invalid! nr tre sa inceapa cu una di ");
    */
    else if(nr.matches("[0][7][2-6]\\d{7}"))
    formatNrTelMobil=nr;
    else throw new IllegalArgumentException("Format invalid!Nr de telefon mobil trebuie sa inceapa cu cifrele 07 urmat de una din cifrele 2,3,4,5,6 si sa aiba 10 cifre!"+ " sau " + "Formatul nr-ului de telefon fix incepe cu cifra 0 urmata de 2-3 dupa care urmeaza alte 8 cifre");
    }




    public String toString(){
    return formatNrTelFix + formatNrTelMobil;
    }
    } " ;

    Class CarteDeTelefon(which means PhoneBook),this class contain the MVC(model view controler) which I implemented. This class contain the following code: "/*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */

    package proiect;


    import java.io.Serializable;
    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.Comparator;
    import java.util.List;
    import javax.swing.AbstractListModel;
    import java.util.*;
    import javax.swing.*;

    /**
    *
    * @author Alinio
    */
    public class CarteDeTelefon extends AbstractListModel implements Serializable{
    private List<Abonat> abonati = new ArrayList<Abonat>();
    //private List abonati=new ArrayList();
    public static final int DUPA_NUME=1;
    public static final int DUPA_PRENUME=2;
    public static final int DUPA_CNP=3;
    public static final int DUPA_NRTELEFON=4;
    public int getSize(){
    return abonati.size();

    }
    public Abonat getElementAt(int index){
    return (Abonat) abonati.get(index);
    }
    public void Adauga(Abonat a){
    abonati.add(a);
    fireContentsChanged(this,-1,-1);
    }


    public void stergere(int poz) {
    abonati.remove(poz);
    fireContentsChanged(this, -1, -1);
    }


    public void modifica(int poz, Abonat abNou) {
    abonati.remove(poz);
    abonati.add(abNou);

    fireContentsChanged(this, -1, -1);
    }

    public void modifica(Abonat abVechi, Abonat abNou) {
    abonati.remove(abVechi);
    abonati.add(abNou);

    fireContentsChanged(this, -1, -1);
    }
    public void sorteaza(int criteriu) {
    switch (criteriu) {
    case DUPA_NUME:
    Collections.sort(abonati, new Comparator() {

    public int compare(Object o1, Object o2) {
    Abonat ab1 = (Abonat) o1;
    Abonat ab2 = (Abonat) o2;
    return ab1.getNume().compareTo(ab2.getNume());
    }
    });

    break;
    case DUPA_PRENUME:
    Collections.sort(abonati, new Comparator() {

    public int compare(Object o1, Object o2) {
    Abonat ab1 = (Abonat) o1;
    Abonat ab2 = (Abonat) o2;
    return ab1.getPrenume().compareTo(ab2.getPrenume());
    }
    });
    break;
    case DUPA_CNP:
    Collections.sort(abonati, new Comparator() {

    public int compare(Object o1, Object o2) {
    Abonat ab1 = (Abonat) o1;
    Abonat ab2 = (Abonat) o2;
    return ab1.getCnp().compareTo(ab2.getCnp());
    }
    });
    break;
    case DUPA_NRTELEFON:
    Collections.sort(abonati,new Comparator(){


    public int compare(Object o1, Object o2) {
    Abonat a1 = (Abonat) o1;
    Abonat a2 = (Abonat) o2;
    return a1.getCnp().compareTo(a2.getCnp());
    }
    });
    }
    fireContentsChanged(this, -1, -1);
    }
    } " ;
    And the last class which I created is Interfata( Or in english "GUI"). Iwill post the code of this class in another message, because if i would post in this message it will be longer than 50000 caracters:" /*

  4. #4
    Pro Alinio is offline Member
    Join Date
    Mar 2009
    Posts
    3
    Rep Power
    0

    Default

    The code for my Gui class is : "* and open the template in the editor.
    */

    /*
    * interfata.java
    *
    * Created on Mar 9, 2009, 11:50:22 PM
    */

    package proiect;

    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.FilenameFilter;
    import java.io.ObjectInputStream;
    import java.io.ObjectOutputStream;
    import java.util.Timer;
    import java.util.TimerTask;
    import javax.swing.JFileChooser;
    import javax.swing.JOptionPane;
    import javax.swing.ImageIcon;
    /**
    *
    * @author Alinio
    */
    public class interfata extends javax.swing.JFrame {
    private CarteDeTelefon c=new CarteDeTelefon();
    Timer t;
    File[] poze;
    int pozaCurenta=0;
    //private DefaultListModel model;
    //private Icon icon;
    boolean save=false;
    File f=null;
    /** Creates new form interfata */

    private void SalvareAutomata() {
    t = new Timer();
    TimerTask tt = new TimerTask() {

    @Override
    public void run() {
    try {
    FileOutputStream fos = new FileOutputStream(f);
    ObjectOutputStream oos = new ObjectOutputStream(fos);
    oos.writeObject(c);
    oos.close();
    } catch (Exception e) {
    JOptionPane.showMessageDialog(jlist,
    e.getMessage(),
    "Exceptie", JOptionPane.ERROR_MESSAGE);
    }
    }
    };
    t.schedule(tt,0,500000);
    }

    public interfata() {
    initComponents();
    final File dir=new File("D:\\DISC D\\folproidenot\\documente");
    poze=dir.listFiles(new FilenameFilter(){
    public boolean accept(File d,String n){
    if(n.toLowerCase().endsWith("Jpg")){
    return true;}
    else{
    return false; }
    }
    });
    if(poze!=null && poze.length>0){
    lreclame.setIcon(new ImageIcon(poze[pozaCurenta].getAbsolutePath()));
    }
    }


    /** 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() {

    jfc = new javax.swing.JFileChooser();
    dDialog = new javax.swing.JDialog();
    lNume = new javax.swing.JLabel();
    lPrenume = new javax.swing.JLabel();
    lCnp = new javax.swing.JLabel();
    lNRTEL = new javax.swing.JLabel();
    tfNume = new javax.swing.JTextField();
    tfPrenume = new javax.swing.JTextField();
    tfCNP = new javax.swing.JTextField();
    tfNrTelefon = new javax.swing.JTextField();
    bdModifica = new javax.swing.JButton();
    bdCancel = new javax.swing.JButton();
    aDialog = new javax.swing.JDialog();
    alnume = new javax.swing.JLabel();
    alprenume = new javax.swing.JLabel();
    alcnp = new javax.swing.JLabel();
    alnrtel = new javax.swing.JLabel();
    atfnume = new javax.swing.JTextField();
    atfprenume = new javax.swing.JTextField();
    atfcnp = new javax.swing.JTextField();
    atfnrtel = new javax.swing.JTextField();
    baAdauga = new javax.swing.JButton();
    baRenunta = new javax.swing.JButton();
    jPopupMenu1 = new javax.swing.JPopupMenu();
    jPopupMenu2 = new javax.swing.JPopupMenu();
    jPopupMenu3 = new javax.swing.JPopupMenu();
    jMenuItem2 = new javax.swing.JMenuItem();
    jMenuItemadauga3 = new javax.swing.JMenuItem();
    jslcrollist = new javax.swing.JScrollPane();
    jlist = new javax.swing.JList();
    lnume = new javax.swing.JLabel();
    lprenume = new javax.swing.JLabel();
    lcnp = new javax.swing.JLabel();
    lNrTel = new javax.swing.JLabel();
    tfnume = new javax.swing.JTextField();
    tfprenume = new javax.swing.JTextField();
    tfCnp = new javax.swing.JTextField();
    tfNrTel = new javax.swing.JTextField();
    badauga = new javax.swing.JButton();
    bsterge = new javax.swing.JButton();
    bsortare = new javax.swing.JButton();
    bcauta = new javax.swing.JButton();
    besire = new javax.swing.JButton();
    pCautare = new javax.swing.JPanel();
    rbnume = new javax.swing.JRadioButton();
    rbprenume = new javax.swing.JRadioButton();
    rbCNP = new javax.swing.JRadioButton();
    rbTelefon = new javax.swing.JRadioButton();
    lcautare = new javax.swing.JLabel();
    tfinput = new javax.swing.JTextField();
    bmodifica = new javax.swing.JButton();
    preclame = new javax.swing.JPanel();
    jScrollPane1 = new javax.swing.JScrollPane();
    lreclame = new javax.swing.JLabel();
    bSlide = new javax.swing.JButton();
    bclear = new javax.swing.JButton();
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jmenuitemopen = new javax.swing.JMenuItem();
    jMenuItemSave = new javax.swing.JMenuItem();
    jMenuItemiesire = new javax.swing.JMenuItem();
    jSeparator1 = new javax.swing.JSeparator();
    jMenu2 = new javax.swing.JMenu();
    jMenuItemadauga = new javax.swing.JMenuItem();
    jMenuItemModifica = new javax.swing.JMenuItem();
    jMenuItem1 = new javax.swing.JMenuItem();
    jSeparator3 = new javax.swing.JSeparator();
    jMenuItemSterge = new javax.swing.JMenuItem();
    jMenu3 = new javax.swing.JMenu();
    jMenuItemInregistrare = new javax.swing.JMenuItem();
    jSeparator2 = new javax.swing.JSeparator();
    jMenuItemAbout = new javax.swing.JMenuItem();

    lNume.setText("Nume");

    lPrenume.setText("Prenume");

    lCnp.setText("CNP");

    lNRTEL.setText("NRTelefon");

    bdModifica.setText("Modifica");
    bdModifica.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    bdModificaActionPerformed(evt);
    }
    });

    bdCancel.setText("Cancel");
    bdCancel.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    bdCancelActionPerformed(evt);
    }
    });

    javax.swing.GroupLayout dDialogLayout = new javax.swing.GroupLayout(dDialog.getContentPane());
    dDialog.getContentPane().setLayout(dDialogLayout);
    dDialogLayout.setHorizontalGroup(
    dDialogLayout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
    .addGroup(dDialogLayout.createSequentialGroup()
    .addContainerGap()
    .addGroup(dDialogLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.LEADING)
    .addComponent(lNume, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(lPrenume)
    .addComponent(lCnp)
    .addComponent(lNRTEL))
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addGroup(dDialogLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.LEADING, false)
    .addComponent(tfNrTelefon)
    .addComponent(tfPrenume)
    .addComponent(tfCNP)
    .addComponent(tfNume, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGap(35, 35, 35)
    .addGroup(dDialogLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.TRAILING)
    .addComponent(bdCancel, javax.swing.GroupLayout.DEFAULT_SIZE, 73, Short.MAX_VALUE)
    .addComponent(bdModifica, javax.swing.GroupLayout.DEFAULT_SIZE, 73, Short.MAX_VALUE))
    .addGap(57, 57, 57))
    );
    dDialogLayout.setVerticalGroup(
    dDialogLayout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
    .addGroup(dDialogLayout.createSequentialGroup()
    .addGap(26, 26, 26)
    .addGroup(dDialogLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.BASELINE)
    .addComponent(lNume)
    .addComponent(tfNume, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(bdModifica, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addGroup(dDialogLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.LEADING)
    .addComponent(lPrenume)
    .addComponent(tfPrenume, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGap(21, 21, 21)
    .addGroup(dDialogLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.LEADING)
    .addGroup(dDialogLayout.createSequentialGroup()
    .addComponent(lCnp)
    .addGap(30, 30, 30)
    .addComponent(bdCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGroup(dDialogLayout.createSequentialGroup()
    .addComponent(tfCNP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(28, 28, 28)
    .addGroup(dDialogLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.BASELINE)
    .addComponent(tfNrTelefon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(lNRTEL))))
    .addContainerGap(90, Short.MAX_VALUE))
    );

    alnume.setText("Nume");

    alprenume.setText("Prenume");

    alcnp.setText("CNP");

    alnrtel.setText("Nr Telefon");

    baAdauga.setText("Adauga");
    baAdauga.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    baAdaugaActionPerformed(evt);
    }
    });

    baRenunta.setText("Renunta");

    javax.swing.GroupLayout aDialogLayout = new javax.swing.GroupLayout(aDialog.getContentPane());
    aDialog.getContentPane().setLayout(aDialogLayout);
    aDialogLayout.setHorizontalGroup(
    aDialogLayout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
    .addGroup(aDialogLayout.createSequentialGroup()
    .addContainerGap()
    .addGroup(aDialogLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.LEADING)
    .addGroup(aDialogLayout.createSequentialGroup()
    .addGroup(aDialogLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.LEADING)
    .addComponent(alcnp)
    .addComponent(alnrtel))
    .addGap(18, 18, 18))
    .addComponent(alprenume)
    .addComponent(alnume, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGap(28, 28, 28)
    .addGroup(aDialogLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.LEADING, false)
    .addComponent(atfnume, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE)
    .addComponent(atfprenume)
    .addComponent(atfcnp)
    .addComponent(atfnrtel))
    .addGap(69, 69, 69)
    .addGroup(aDialogLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.LEADING)
    .addComponent(baAdauga)
    .addComponent(baRenunta))
    .addContainerGap(23, Short.MAX_VALUE))
    );

    aDialogLayout.linkSize(javax.swing.SwingConstants. HORIZONTAL, new java.awt.Component[] {alcnp, alnrtel, alnume, alprenume});

    aDialogLayout.setVerticalGroup(
    aDialogLayout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
    .addGroup(aDialogLayout.createSequentialGroup()
    .addGap(59, 59, 59)
    .addGroup(aDialogLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.BASELINE)
    .addComponent(atfnume)
    .addComponent(baAdauga, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(alnume))
    .addGroup(aDialogLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.LEADING)
    .addGroup(aDialogLayout.createSequentialGroup()
    .addGap(12, 12, 12)
    .addGroup(aDialogLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.BASELINE)
    .addComponent(atfprenume, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(alprenume))
    .addGap(31, 31, 31)
    .addGroup(aDialogLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.BASELINE)
    .addComponent(alcnp)
    .addComponent(atfcnp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGap(27, 27, 27)
    .addGroup(aDialogLayout.createParallelGroup(javax. swing.GroupLayout.Alignment.BASELINE)
    .addComponent(alnrtel)
    .addComponent(atfnrtel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addContainerGap(53, Short.MAX_VALUE))
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILI NG, aDialogLayout.createSequentialGroup()
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addComponent(baRenunta, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(41, 41, 41))))
    );

    aDialogLayout.linkSize(javax.swing.SwingConstants. VERTICAL, new java.awt.Component[] {alcnp, alnrtel, alnume, alprenume});

    jMenuItem2.setText("jMenuItem2");
    jPopupMenu3.add(jMenuItem2);

    jMenuItemadauga3.setText("jMenuItem3");
    jMenuItemadauga3.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jMenuItemadauga3ActionPerformed(evt);
    }
    });
    jPopupMenu3.add(jMenuItemadauga3);

    setDefaultCloseOperation(javax.swing.WindowConstan ts.EXIT_ON_CLOSE);

    jlist.setModel(c);
    jslcrollist.setViewportView(jlist);

    lnume.setText("Nume");

    lprenume.setText("Prenume");

    lcnp.setText("CNP");

    lNrTel.setText("NrTelefon");

    badauga.setText("Adauga");
    badauga.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    badaugaActionPerformed(evt);
    }
    });

    bsterge.setText("Sterge");
    bsterge.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mousePressed(java.awt.event.MouseEvent evt) {
    bstergeMousePressed(evt);
    }
    });
    bsterge.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
    public void mouseDragged(java.awt.event.MouseEvent evt) {
    bstergeMouseDragged(evt);
    }
    });
    bsterge.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    bstergeActionPerformed(evt);
    }
    });

    bsortare.setText("Sortare");

    bcauta.setText("Cauta");

    besire.setText("Exit");
    besire.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    besireActionPerformed(evt);
    }
    });

    pCautare.setBorder(javax.swing.BorderFactory.creat eTitledBorder("Sortare"));

    rbnume.setText("Nume");
    rbnume.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    rbnumeActionPerformed(evt);
    }
    });

    rbprenume.setText("Prenume");
    rbprenume.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    rbprenumeActionPerformed(evt);
    }
    });

    rbCNP.setText("CNP");
    rbCNP.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    rbCNPActionPerformed(evt);
    }
    });

    rbTelefon.setText("NrTelefon");
    rbTelefon.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    rbTelefonActionPerformed(evt);
    }
    });

    javax.swing.GroupLayout pCautareLayout = new javax.swing.GroupLayout(pCautare);
    pCautare.setLayout(pCautareLayout);
    pCautareLayout.setHorizontalGroup(
    pCautareLayout.createParallelGroup(javax.swing.Gro upLayout.Alignment.LEADING)
    .addGroup(pCautareLayout.createSequentialGroup()
    .addGroup(pCautareLayout.createParallelGroup(javax .swing.GroupLayout.Alignment.LEADING)
    .addComponent(rbnume)
    .addComponent(rbprenume)
    .addComponent(rbCNP)
    .addComponent(rbTelefon))
    .addContainerGap(18, Short.MAX_VALUE))
    );
    pCautareLayout.setVerticalGroup(
    pCautareLayout.createParallelGroup(javax.swing.Gro upLayout.Alignment.LEADING)
    .addGroup(pCautareLayout.createSequentialGroup()
    .addContainerGap()
    .addComponent(rbnume)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
    .addComponent(rbprenume)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
    .addComponent(rbCNP)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addComponent(rbTelefon)
    .addContainerGap(javax.swing.GroupLayout.DEFAULT_S IZE, Short.MAX_VALUE))
    );

    lcautare.setText("Cauta");

    bmodifica.setText("Modifica");
    bmodifica.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    bmodificaActionPerformed(evt);
    }
    });

    lreclame.setText("Not image yet");
    jScrollPane1.setViewportView(lreclame);

    javax.swing.GroupLayout preclameLayout = new javax.swing.GroupLayout(preclame);
    preclame.setLayout(preclameLayout);
    preclameLayout.setHorizontalGroup(
    preclameLayout.createParallelGroup(javax.swing.Gro upLayout.Alignment.LEADING)
    .addGroup(preclameLayout.createSequentialGroup()
    .addContainerGap()
    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 353, Short.MAX_VALUE)
    .addContainerGap())
    );
    preclameLayout.setVerticalGroup(
    preclameLayout.createParallelGroup(javax.swing.Gro upLayout.Alignment.LEADING)
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILI NG, preclameLayout.createSequentialGroup()
    .addContainerGap()
    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 112, Short.MAX_VALUE))
    );

    bSlide.setText("Slide");
    bSlide.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    bSlideActionPerformed(evt);
    }
    });

    bclear.setText("Clear");
    bclear.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    bclearActionPerformed(evt);
    }
    });

    jMenu1.setText("File");

    jmenuitemopen.setAccelerator(javax.swing.KeyStroke .getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.ALT_MASK));
    jmenuitemopen.setText("Open");
    jmenuitemopen.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jmenuitemopenActionPerformed(evt);
    }
    });
    jMenu1.add(jmenuitemopen);

    jMenuItemSave.setAccelerator(javax.swing.KeyStroke .getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK));
    jMenuItemSave.setText("Save");
    jMenuItemSave.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jMenuItemSaveActionPerformed(evt);
    }
    });
    jMenu1.add(jMenuItemSave);

    jMenuItemiesire.setAccelerator(javax.swing.KeyStro ke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.ALT_MASK));
    jMenuItemiesire.setText("Iesire");
    jMenuItemiesire.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jMenuItemiesireActionPerformed(evt);
    }
    });
    jMenu1.add(jMenuItemiesire);
    jMenu1.add(jSeparator1);

    jMenuBar1.add(jMenu1);

    jMenu2.setText("Abonat");

    jMenuItemadauga.setAccelerator(javax.swing.KeyStro ke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK));
    jMenuItemadauga.setText("Adauga");
    jMenuItemadauga.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jMenuItemadaugaActionPerformed(evt);
    }
    });
    jMenu2.add(jMenuItemadauga);

    jMenuItemModifica.setAccelerator(javax.swing.KeySt roke.getKeyStroke(java.awt.event.KeyEvent.VK_M, java.awt.event.InputEvent.CTRL_MASK));
    jMenuItemModifica.setText("Modifica");
    jMenuItemModifica.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jMenuItemModificaActionPerformed(evt);
    }
    });
    jMenu2.add(jMenuItemModifica);

    jMenuItem1.setAccelerator(javax.swing.KeyStroke.ge tKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK));
    jMenuItem1.setText("Cauta");
    jMenu2.add(jMenuItem1);
    jMenu2.add(jSeparator3);

    jMenuItemSterge.setAccelerator(javax.swing.KeyStro ke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
    jMenuItemSterge.setText("Sterge");
    jMenuItemSterge.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jMenuItemStergeActionPerformed(evt);
    }
    });
    jMenu2.add(jMenuItemSterge);

    jMenuBar1.add(jMenu2);

    jMenu3.setText("Help");

    jMenuItemInregistrare.setAccelerator(javax.swing.K eyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I , java.awt.event.InputEvent.SHIFT_MASK));
    jMenuItemInregistrare.setText("Inregistrare");
    jMenuItemInregistrare.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jMenuItemInregistrareActionPerformed(evt);
    }
    });
    jMenu3.add(jMenuItemInregistrare);
    jMenu3.add(jSeparator2);

    jMenuItemAbout.setAccelerator(javax.swing.KeyStrok e.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.SHIFT_MASK));
    jMenuItemAbout.setText("About");
    jMenu3.add(jMenuItemAbout);

    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.G roupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addComponent(pCautare, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(18, 18, 18)
    .addComponent(bsortare))
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING, false)
    .addComponent(lprenume, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addComponent(lnume, javax.swing.GroupLayout.DEFAULT_SIZE, 60, Short.MAX_VALUE)
    .addComponent(lcnp, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addComponent(lNrTel, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(lcautare, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING, false)
    .addComponent(tfinput)
    .addComponent(tfNrTel)
    .addComponent(tfCnp)
    .addComponent(tfprenume)
    .addComponent(tfnume, javax.swing.GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE))))
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING, false)
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addComponent(badauga)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
    .addComponent(bsterge))
    .addComponent(bcauta))
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addComponent(jslcrollist, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGroup(layout.createSequentialGroup()
    .addGap(8, 8, 8)
    .addComponent(bmodifica)
    .addGap(18, 18, 18)
    .addComponent(bclear, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED, 133, Short.MAX_VALUE)
    .addComponent(besire))))
    .addGroup(layout.createSequentialGroup()
    .addComponent(preclame, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addComponent(bSlide)))
    .addGap(47, 47, 47))
    );

    layout.linkSize(javax.swing.SwingConstants.HORIZON TAL, new java.awt.Component[] {badauga, bcauta, bsortare, bsterge});

    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addContainerGap()
    .addComponent(jslcrollist, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
    .addComponent(besire)
    .addComponent(bsortare)
    .addComponent(badauga)
    .addComponent(bsterge)
    .addComponent(bmodifica)
    .addComponent(bclear))
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addComponent(preclame, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILI NG, layout.createSequentialGroup()
    .addComponent(bSlide)
    .addGap(57, 57, 57))))
    .addGroup(layout.createSequentialGroup()
    .addGap(38, 38, 38)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
    .addComponent(lnume, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(tfnume, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
    .addComponent(lprenume, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(tfprenume, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
    .addComponent(lcnp, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(tfCnp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING)
    .addComponent(tfNrTel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(lNrTel, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGap(18, 18, 18)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
    .addComponent(lcautare, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(tfinput, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(bcauta))
    .addGap(18, 18, 18)
    .addComponent(pCautare, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
    .addContainerGap())
    );

    pack();
    }// </editor-fold>

    private void badaugaActionPerformed(java.awt.event.ActionEvent evt) {
    String Nume=tfnume.getText();
    String Prenume=tfprenume.getText();
    String CNP=tfCnp.getText();
    NrTel nrtel=new NrTel(tfNrTel.getText());

    //Abonat a=null;
    try{
    Abonat a=new Abonat(Nume,Prenume,CNP,nrtel);
    c.Adauga(a);
    }catch(IllegalArgumentException e){
    JOptionPane.showMessageDialog(this, "Format invalid", "Eroare", JOptionPane.ERROR_MESSAGE);
    }



    // TODO add your handling code here:
    }

    private void jmenuitemopenActionPerformed(java.awt.event.Action Event evt) {
    if(jfc.showOpenDialog(this)==JFileChooser.APPROVE_ OPTION){
    try{
    f=jfc.getSelectedFile();
    FileInputStream fos=new FileInputStream(f);
    ObjectInputStream oos=new ObjectInputStream(fos);
    c=(CarteDeTelefon)oos.readObject();

    jlist.setModel(c);
    oos.close();
    }
    catch(Exception e){
    JOptionPane.showMessageDialog(this,e.getMessage(), "Eroare",JOptionPane.ERROR_MESSAGE);
    }

    }


    }

    private void jMenuItemSaveActionPerformed(java.awt.event.Action Event evt) {
    if (save == false) {
    if (jfc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
    try {
    f = jfc.getSelectedFile();
    FileOutputStream fos = new FileOutputStream(f);
    ObjectOutputStream oos = new ObjectOutputStream(fos);
    oos.writeObject(c);
    oos.close();
    save = true;
    SalvareAutomata();
    } catch (Exception e) {
    JOptionPane.showMessageDialog(this, e.getMessage(),
    "Exceptie", JOptionPane.ERROR_MESSAGE);
    }
    }
    } else {
    try {
    FileOutputStream fos = new FileOutputStream(f);
    ObjectOutputStream oos = new ObjectOutputStream(fos);
    oos.writeObject(c);
    oos.close();
    } catch (Exception e) {
    JOptionPane.showMessageDialog(this, e.getMessage(),
    "Exceptie", JOptionPane.ERROR_MESSAGE);
    }
    }
    // TODO add your handling code here:
    }

    private void jMenuItemiesireActionPerformed(java.awt.event.Acti onEvent evt) {
    int n=JOptionPane.showConfirmDialog(this, "Doriti sa parasiti aplicatia?", "Atentie",JOptionPane.YES_NO_OPTION);
    if(n==JOptionPane.YES_OPTION){
    System.exit(0);
    }else{
    JOptionPane.showMessageDialog(this, "Ati ales sa utilizati in continuare aplicatia!");
    }
    // TODO add your handling code here:
    }

    private void besireActionPerformed(java.awt.event.ActionEvent evt) {
    int n=JOptionPane.showConfirmDialog(this, "Sunteti sigur ca vreti sa parasiti aplicatia?", "Atentie!", JOptionPane.YES_NO_OPTION);
    if(n==JOptionPane.YES_OPTION){
    System.exit(0);
    }else{
    JOptionPane.showMessageDialog(this, "Ati ales sa utilizati in continuare aplicatia");
    }
    //System.exit(0);// TODO add your handling code here:
    }

    private void jMenuItemInregistrareActionPerformed(java.awt.even t.ActionEvent evt) {

    // JOptionPane.showInputDialog(this,"introduceti codul de inregistrare:\n " + " Codul de inregistrare este ... ","Customized Diaolog",JOptionPane.PLAIN_MESSAGE,icon,posibiliti es,"ham"); // TODO add your handling code here:
    }

    private void bSlideActionPerformed(java.awt.event.ActionEvent evt) {
    if(bSlide.isSelected()){


    t=new Timer();
    TimerTask tt=new TimerTask(){
    public void run(){
    pozaCurenta=++pozaCurenta%poze.length;
    lreclame.setIcon( new ImageIcon(poze[pozaCurenta].getAbsolutePath()));

    }
    };
    t.schedule(tt,0, 3000);
    }
    else{
    t.cancel();
    }
    // TODO add your handling code here:
    }

    private void bstergeActionPerformed(java.awt.event.ActionEvent evt) {

    if (JOptionPane.showConfirmDialog(this,
    "Sunteti sigur da doriti sa stergeti?")==0)
    c.stergere(jlist.getSelectedIndex());

    // TODO add your handling code here:
    }

    private void rbnumeActionPerformed(java.awt.event.ActionEvent evt) {
    c.sorteaza(CarteDeTelefon.DUPA_NUME); // TODO add your handling code here:
    }

    private void rbprenumeActionPerformed(java.awt.event.ActionEven t evt) {
    c.sorteaza(CarteDeTelefon.DUPA_PRENUME); // TODO add your handling code here:
    }

    private void rbCNPActionPerformed(java.awt.event.ActionEvent evt) {
    c.sorteaza(CarteDeTelefon.DUPA_CNP); // TODO add your handling code here:
    }

    private void rbTelefonActionPerformed(java.awt.event.ActionEven t evt) {
    c.sorteaza(CarteDeTelefon.DUPA_NRTELEFON);
    // TODO add your handling code here:
    }

    private void bmodificaActionPerformed(java.awt.event.ActionEven t evt) {
    try {
    int pozitie = jlist.getSelectedIndex();
    tfNume.setText(c.getElementAt(pozitie).getNume());
    tfPrenume.setText(c.getElementAt(pozitie).getPrenu me());
    tfNrTelefon.setText(c.getElementAt(pozitie).getNrt el());
    tfCNP.setText(c.getElementAt(pozitie).getCnp());
    dDialog.setAlwaysOnTop(true);
    dDialog.setVisible(true);
    dDialog.pack();
    } catch (ArrayIndexOutOfBoundsException aioobe) {
    JOptionPane.showMessageDialog(this,
    "Trebuie sa selectati o persoana din lista!",
    "Exceptie", JOptionPane.INFORMATION_MESSAGE);
    }
    // TODO add your handling code here:
    }

    private void bdCancelActionPerformed(java.awt.event.ActionEvent evt) {
    //dDialog.setAlwaysOnTop(true);
    if (JOptionPane.showConfirmDialog(this,
    "Sunteti sigur da doriti sa parasiti aceasta fereastra?")==0) {
    dDialog.setVisible(false);
    }// TODO add your handling code here:
    }

    private void bdModificaActionPerformed(java.awt.event.ActionEve nt evt) {

    NrTel nrtel=new NrTel(tfNrTelefon.getText());
    Abonat abNou=new Abonat(tfNume.getText(),tfPrenume.getText(),tfCNP. getText(),nrtel);

    c.modifica(jlist.getSelectedIndex(),abNou );
    dDialog.setVisible(false);

    // TODO add your handling code here:
    }

    private void jMenuItemModificaActionPerformed(java.awt.event.Ac tionEvent evt) {
    try {
    int pozitie = jlist.getSelectedIndex();
    tfNume.setText(c.getElementAt(pozitie).getNume());
    tfPrenume.setText(c.getElementAt(pozitie).getPrenu me());
    tfNrTelefon.setText(c.getElementAt(pozitie).getNrt el());
    tfCNP.setText(c.getElementAt(pozitie).getCnp());
    dDialog.setAlwaysOnTop(true);
    dDialog.setVisible(true);
    dDialog.pack();
    } catch (ArrayIndexOutOfBoundsException aioobe) {
    JOptionPane.showMessageDialog(this,
    "Trebuie sa selectati o persoana din lista!",
    "Exceptie", JOptionPane.INFORMATION_MESSAGE);
    }


    // TODO add your handling code here:
    }

    private void baAdaugaActionPerformed(java.awt.event.ActionEvent evt) {
    NrTel nr=new NrTel(atfnrtel.getText());
    Abonat a=null;
    try{
    a=new Abonat(atfnume.getText(),atfprenume.getText(),atfc np.getText(),nr);
    }catch(IllegalArgumentException e){
    JOptionPane.showMessageDialog(this, "Format invalid!Introduceti datele cu atentie", "Eroare!", JOptionPane.ERROR_MESSAGE);
    }
    c.Adauga(a);
    int n=JOptionPane.showConfirmDialog(this, "Doriti sa mai adaugati un client in lista?", "Atentie",JOptionPane.YES_NO_OPTION);
    if(n==JOptionPane.NO_OPTION){
    aDialog.setVisible(false);
    }else{
    JOptionPane.showMessageDialog(this, "Adaugati un nou client!");
    }

    // TODO add your handling code here:
    }

    private void jMenuItemadaugaActionPerformed(java.awt.event.Acti onEvent evt) {

    aDialog.setAlwaysOnTop(true);
    aDialog.setVisible(true);
    aDialog.pack();// TODO add your handling code here:
    }

    private void bclearActionPerformed(java.awt.event.ActionEvent evt) {
    tfnume.setText("");
    tfprenume.setText("");
    tfCnp.setText("");
    tfNrTel.setText("");// TODO add your handling code here:
    }

    private void bstergeMouseDragged(java.awt.event.MouseEvent evt) {
    // TODO add your handling code here:
    }

    private void bstergeMousePressed(java.awt.event.MouseEvent evt) {
    //saySomething("Acest buton sterge un abonat din agenda",evt); // TODO add your handling code here:
    }

    private void jMenuItemStergeActionPerformed(java.awt.event.Acti onEvent evt) {
    int index = jlist.getSelectedIndex();
    if (index == -1) {
    JOptionPane.showMessageDialog(this,
    "Nu ati selectat o persoana din lista!Pentru a putea sa stergeti o persoana din listatrebuie sa o selectati",
    "Atentie", JOptionPane.INFORMATION_MESSAGE);
    } else if (JOptionPane.showConfirmDialog(this,
    "Sunteti sigur ca doriti sa stergeti persoana selectata?") == 0) {
    c.stergere(index);
    } // TODO add your handling code here:
    }

    private void jMenuItemadauga3ActionPerformed(java.awt.event.Act ionEvent evt) {
    try {
    int pozitie = jlist.getSelectedIndex();
    tfNume.setText(c.getElementAt(pozitie).getNume());
    tfPrenume.setText(c.getElementAt(pozitie).getPrenu me());
    tfNrTelefon.setText(c.getElementAt(pozitie).getNrt el());
    tfCNP.setText(c.getElementAt(pozitie).getCnp());
    dDialog.setAlwaysOnTop(true);
    dDialog.setVisible(true);
    dDialog.pack();
    } catch (ArrayIndexOutOfBoundsException aioobe) {
    JOptionPane.showMessageDialog(this,
    "Trebuie sa selectati o persoana din lista!",
    "Exceptie", JOptionPane.INFORMATION_MESSAGE);
    }
    // TODO add your handling code here:
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new interfata().setVisible(true);
    }
    });
    }

    // Variables declaration - do not modify
    private javax.swing.JDialog aDialog;
    private javax.swing.JLabel alcnp;
    private javax.swing.JLabel alnrtel;
    private javax.swing.JLabel alnume;
    private javax.swing.JLabel alprenume;
    private javax.swing.JTextField atfcnp;
    private javax.swing.JTextField atfnrtel;
    private javax.swing.JTextField atfnume;
    private javax.swing.JTextField atfprenume;
    private javax.swing.JButton bSlide;
    private javax.swing.JButton baAdauga;
    private javax.swing.JButton baRenunta;
    private javax.swing.JButton badauga;
    private javax.swing.JButton bcauta;
    private javax.swing.JButton bclear;
    private javax.swing.JButton bdCancel;
    private javax.swing.JButton bdModifica;
    private javax.swing.JButton besire;
    private javax.swing.JButton bmodifica;
    private javax.swing.JButton bsortare;
    private javax.swing.JButton bsterge;
    private javax.swing.JDialog dDialog;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItemAbout;
    private javax.swing.JMenuItem jMenuItemInregistrare;
    private javax.swing.JMenuItem jMenuItemModifica;
    private javax.swing.JMenuItem jMenuItemSave;
    private javax.swing.JMenuItem jMenuItemSterge;
    private javax.swing.JMenuItem jMenuItemadauga;
    private javax.swing.JMenuItem jMenuItemadauga3;
    private javax.swing.JMenuItem jMenuItemiesire;
    private javax.swing.JPopupMenu jPopupMenu1;
    private javax.swing.JPopupMenu jPopupMenu2;
    private javax.swing.JPopupMenu jPopupMenu3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JFileChooser jfc;
    private javax.swing.JList jlist;
    private javax.swing.JMenuItem jmenuitemopen;
    private javax.swing.JScrollPane jslcrollist;
    private javax.swing.JLabel lCnp;
    private javax.swing.JLabel lNRTEL;
    private javax.swing.JLabel lNrTel;
    private javax.swing.JLabel lNume;
    private javax.swing.JLabel lPrenume;
    private javax.swing.JLabel lcautare;
    private javax.swing.JLabel lcnp;
    private javax.swing.JLabel lnume;
    private javax.swing.JLabel lprenume;
    private javax.swing.JLabel lreclame;
    private javax.swing.JPanel pCautare;
    private javax.swing.JPanel preclame;
    private javax.swing.JRadioButton rbCNP;
    private javax.swing.JRadioButton rbTelefon;
    private javax.swing.JRadioButton rbnume;
    private javax.swing.JRadioButton rbprenume;
    private javax.swing.JTextField tfCNP;
    private javax.swing.JTextField tfCnp;
    private javax.swing.JTextField tfNrTel;
    private javax.swing.JTextField tfNrTelefon;
    private javax.swing.JTextField tfNume;
    private javax.swing.JTextField tfPrenume;
    private javax.swing.JTextField tfinput;
    private javax.swing.JTextField tfnume;
    private javax.swing.JTextField tfprenume;
    // End of variables declaration

    }" !!!! This is all that I did until then! I hope, that Msiter Fubarable will see again what I posted!!!

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    That's too much code for me to go through, and unformatted at that. I recommend that you try to solve your problem in a small program first, then if you figure out the solution, change your big program so that it works, and if you don't figure out the solution, then you can post the small program, which will hopefully be a reasonable amount of code to ask a volunteer to review.

    Best of luck.

Similar Threads

  1. How to use a JList?
    By glhansen in forum New To Java
    Replies: 3
    Last Post: 03-24-2009, 11:27 AM
  2. JList
    By pinks_70986 in forum New To Java
    Replies: 1
    Last Post: 02-12-2009, 09:36 AM
  3. About JList
    By hungleon88 in forum Advanced Java
    Replies: 5
    Last Post: 08-30-2008, 10:24 PM
  4. Replies: 5
    Last Post: 08-26-2008, 04:43 PM
  5. Help with JList
    By Albert in forum NetBeans
    Replies: 1
    Last Post: 07-13-2007, 04:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •