Oppure

Loading
16/02/10 12:51
killer
salve ragazzi posseggo un vettore d'oggetti di classe Vector.
posseggo una jTable...
e praticamente attraverso l'inserimento di una stringa in una jtextfield, vorrei eseguire una ricerca che mi evidenzi di blu l'oggetto trovato in una row della jtable..come fare cio ?!!
rispondetemi presto grazie.
aaa
08/05/10 12:37
tekdu
se ho ben capito il problema credo che dovresti fare qlks del genere:

	public int findIndex(String Name) throws Exception{
	for(int i=0;i<vector.size();i++){
			if ((oggetto)(vector.get(i)).getName.compareTo(Name)==1)
				return i;
			}
		}
		throw new Exception("not found");
	}

e poi per ricercare
this.btnSearch.addActionListener(new ActionListener(){
		public void actionPerformed(ActionEvent e) {
			try {
				int i= findIndex(txtField.getText());
				Jtable.setSelectedIndex(i);
			} catch (Exception e1) {
                         JOptionPane.showMessageDialog(MainWindow.this, e1.getMessage(),
						"not found", JOptionPane.ERROR_MESSAGE); 
			}
		}

	});


+ o - dovrebbe funzionare...
aaa
08/05/10 12:37
tekdu
se ho ben capito il problema credo che dovresti fare qlks del genere:

	public int findIndex(String Name) throws Exception{
	for(int i=0;i<vector.size();i++){
			if ((oggetto)(vector.get(i)).getName.compareTo(Name)==1)
				return i;
			}
		}
		throw new Exception("not found");
	}

e poi per ricercare
this.btnSearch.addActionListener(new ActionListener(){
		public void actionPerformed(ActionEvent e) {
			try {
				int i= findIndex(txtField.getText());
				Jtable.setSelectedIndex(i);
			} catch (Exception e1) {
                         JOptionPane.showMessageDialog(MainWindow.this, e1.getMessage(),
						"not found", JOptionPane.ERROR_MESSAGE); 
			}
		}

	});


+ o - dovrebbe funzionare...
aaa