• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Need Help...  RSS feed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i doing a seach function... gettin input from the textfield... and seacrh inside an arraylist of a guest list... just want to take out the "name" of all the data from the list to search... i've tried with all these codes, can complie and execute but the search button not working, no respose at all....
Hope someone out there can help...
Thanx alot..

public void actionPerformed (ActionEvent e){

if (e.getSource()==clearBtn) {
clear();
}

if (e.getSource()==searchBtn) {
String nameInput = searchTf.getText();
if (nameInput.length()!=0)
searchName(nameInput); //pass nameInput to method for searching and display result
else
JOptionPane.showMessageDialog(this, "Please enter a name to search", "Error", JOptionPane.INFORMATION_MESSAGE);
}
}
//other codings to perform tasks when other
private void searchName(String nameInput) {
boolean exist=false;
GuestFile r = null;
for (int i=0; i<guestsList.size(); i++) {
r = (GuestFile)guestsList.get(i);
if ((r.getName()).equals(nameInput)) {
exist = true;
//break;
}
if (false)
JOptionPane.showMessageDialog(this, "guest found", "Information", JOptionPane.INFORMATION_MESSAGE);
else
JOptionPane.showMessageDialog(this, "not found", "Error", JOptionPane.ERROR_MESSAGE);
clear();
}
}
public void clear(){
searchTf.setText("");
}
}
[ April 17, 2004: Message edited by: Jessie Tan ]
[ April 17, 2004: Message edited by: Gregg Bolinger ]
 
author and iconoclast
Posts: 24203
43
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jessie,
Welcome to JavaRanch!
I suspect you meant this line
if (false)
to say
if (exist)
Otherwise, looks correct.
 
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jessie,
We can all empathise with needing answers "urgently" but specifying so in your subject will most often get your questions igored. We regard everyones questions with the same level of urgency. There are no questions more or less important than others.
I edited your post to remove the word urgent.
I would also recomend that future subjects contain something to do with your question. While this is not a requirement of the Ranch, it is good practice.
 
Jessie Tan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Ernest Friedman-Hill:
Hi Jessie,
Welcome to JavaRanch!
I suspect you meant this line
if (false)
to say
if (exist)
Otherwise, looks correct.


Thanx
 
These are not the droids you are looking for. Perhaps I can interest you in a tiny ad?
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!