Searching a Text Field in a JList Programming Software Development by no1zson …) { JTextField f = (JTextField)e.getSource(); final String s = f.getText(); SwingUtilites.invokeLate(new Runnable() { public void run() { try { for(int i… Re: What is the technical name for the call to javax.swing.SwingUtilities.invokeLater? Programming Software Development by FALL3N … because an EDT has an overriding 'run()' method? 'javax.swing.SwingUtilites' runs the invokeLater() method, but what is 'javax.swing….SwingUtilites' an instance of? I guess it is an instance of … Re: What is the technical name for the call to javax.swing.SwingUtilities.invokeLater? Programming Software Development by JamesCherrill … classes and methods within Swing that use it. javax.swing.SwingUtilites is a perfectly ordinary class, like javax.swing.JLabel or… Re: Searching a Text Field in a JList Programming Software Development by peter_budo Regular expression is answer to your problem. Ofcourse you can do it with substrings, but it is dirty work. Read up Sun tutorial on regular expressions [URL="http://java.sun.com/docs/books/tutorial/essential/regex/"]here[/URL] Re: Searching a Text Field in a JList Programming Software Development by Ezzaral [QUOTE] 1st - This listener seems to be a CaretListener .... how will that work with my ActionListener and my SEARCH button?[/QUOTE] It won't as written. It will respond to any text change in your cd name field and perform a search on the list for an incremental match. If you want this to only occur when search is pressed you will need a state … Re: Searching a Text Field in a JList Programming Software Development by TheGathering I can't even run that code and see. The code you pasted has all kinds of weird errors. [code]Exception in thread "main" java.lang.UnsatisfiedLinkError: java.awt.Toolkit.init IDs()V at java.awt.Toolkit.initIDs(Native Method) at java.awt.Toolkit.<clinit>(Toolkit.java:1619) at java.awt.Component.<… Re: Searching a Text Field in a JList Programming Software Development by no1zson All kinds of weird erros ... welcome to my day! :o) I know one thing, I recognize and understand almost every error I see now ... I may not be able to fix it, but it is all familiar territory. I had not even thought about an additional Search field Ezzaral. That sounds a lot easier than what I have been reading. I can make another field and … Re: Searching a Text Field in a JList Programming Software Development by Ezzaral If Search is clicked and there is text in the search field, you just need to compare that to the cd names in the list model and if you have a match (or partial match if you wish), select that cd object. Re: Searching a Text Field in a JList Programming Software Development by no1zson I only want full match, or a message stating No Match ... I cannot find any docs on how to do this. Only thing I have found close is FindMatchingItem, but there are not a lot of examples to go off of with that. Is any of the code I had before useable? That is about the only thing close to what I am looking for that I have found. Re: Searching a Text Field in a JList Programming Software Development by Ezzaral You merely need to break down my previous post into steps and think about what each of those requires. You have text in a search field that you want to compare to the name (or title or whatever) property of each cd object in the list. The only way to do that is to loop through those and check for a match on each one. If one matches, you can make … Re: Searching a Text Field in a JList Programming Software Development by no1zson I cant believe this actually works ... kind of ... it puts the wrong cd in there, but that is a currCD issue I need to work on. This seems too easy ... is it right? [CODE]private void btnSearchActionPerformed(ActionEvent evt) { if (searchField == cdNameField); CdwArtist newCD = (CdwArtist) listModel.get( currCD ); … Re: Searching a Text Field in a JList Programming Software Development by Ezzaral Well, that doesn't really do anything at all beyond put the current cd info into your text fields. You will of course want to do that - after you have found the appropriate cd in the list model. This statement does nothing whatsoever: [inlinecode]if (searchField == cdNameField);[/inlinecode] Re: Searching a Text Field in a JList Programming Software Development by no1zson I knew that was too easy. Where can I find something on how to do that compare? Re: Searching a Text Field in a JList Programming Software Development by Ezzaral You have all the knowledge to do it already, you just need to think about it. a) You need to loop through the listModel. b) You need to get the cd object and compare it's name property to the string you are looking for. c) if it's a match, you need to make that the current cd d) you need to set the text field values to the new current cd values. I… Re: Searching a Text Field in a JList Programming Software Development by no1zson I am trying to put it together, but I have holes in my knowledge. Step 1, Go to first element ... I know how to do this. Step 2. Is to compare the cdNameField to my new searchField. I do not know how to do this. Step 3. If Step 2 is a match .. fill fields. I know how to fill fields, but not how to structure this IF statement with what follows. … Re: Searching a Text Field in a JList Programming Software Development by Ezzaral You already had a pretty good start on the searching in that first post. The only issue there is that instead of [code] String item = (String)listModel.elementAt(i);[/code] you would instead want to get [code] CdwArtist cdEntry = (CdwArtist)listModel.elementAt(i);[/code] Using a boolean such as "matchFound" which is flagged on a match, … Re: Searching a Text Field in a JList Programming Software Development by no1zson I knew this would be hard, that is why I saved it for the end, but man! I never expected it to be this bad. I think I actually understand LESS than I did this morning! :o) I am going to the gym, going home and play with my little one, and then try somemore before I go to bed. Right now, this is what I have, and it is erroring all over the … Re: Searching a Text Field in a JList Programming Software Development by Ezzaral [quote]It cannot find symbol e form e.getSource, or item from item.substring (and honestly I do not even know what these two things are) and to top that off my dialog box does not work either.[/quote] Well, look at your code and you will see that you don't have variables "e" or "item". You don't need e.getSource() any longer … Re: Searching a Text Field in a JList Programming Software Development by no1zson [QUOTE=Ezzaral;413489]Well, look at your code and you will see that you don't have variables "e" or "item". You don't need e.getSource() any longer anyway because you can just get the text to search for from your text field (e.getSource() was getting a reference to the component that you had the caret listener attached to). You … Re: Searching a Text Field in a JList Programming Software Development by no1zson Between late last night and early this morning I have put in about 3 hours on this, and my progress is somewhat disapointing to me. The searches have always given me problem. The code never looks like my brain thinks it should. The showMessage was easy enough, quick reading and typing had me leaving out a variable there. [CODE]JOptionPane.… Re: Searching a Text Field in a JList Programming Software Development by peter_budo You can replace "f, e & s" with names you want to use that was just quick example from Ezzaral. He should also remember that even if he is giving small code examples he should use meaningfull names to avoid confusion like now :). This statement [inlinecode]CdwArtist cdEntry = (CdwArtist)listModel.elementAt(i);[/inlinecode] will … Re: Searching a Text Field in a JList Programming Software Development by Ezzaral [quote=no1zson;413818]First Question, this entire statment. Are these variables, f, e, and s really just generic terms for me to replace with my information, or are they meant to be taken literally? [code]JTextField f = (JTextField)e.getSource(); final String s = f.getText(); [/code] f, is this really just my searchField? I cannot … Re: Searching a Text Field in a JList Programming Software Development by Ezzaral [quote=peter_budo;413865]You can replace "f, e & s" with names you want to use that was just quick example from Ezzaral. He should also remember that even if he is giving small code examples he should use meaningfull names to avoid confusion like now :). [/quote] Actually those variables came from the code sample he got elsewhere for… Re: Searching a Text Field in a JList Programming Software Development by peter_budo My appology then :) Re: Searching a Text Field in a JList Programming Software Development by Ezzaral [quote=peter_budo;413874]My appology then :)[/quote] hehe... no worries, there are a lot of code fragments floating around here. Re: Searching a Text Field in a JList Programming Software Development by no1zson Peter - it will be everything I can do to get through one search here without eating a bullet, at this point I do not want to compound my lack of understanding by making it more difficult. I think the break should stay for now. ;) I have never used a Boolean before (this just gets better and better). Is it absolutley necessary here, easier, … Re: Searching a Text Field in a JList Programming Software Development by no1zson [QUOTE=Ezzaral;413879]hehe... no worries, there are a lot of code fragments floating around here.[/QUOTE] sorry. :$ It is the only way I have found that I can make sense of most of this. Until I see it down in code, and can see how information flows through what is written, see how the input and output works, then it is just words on the … Re: Searching a Text Field in a JList Programming Software Development by TheGathering [QUOTE=no1zson;413884] I have never used a Boolean before (this just gets better and better). Is it absolutley necessary here, easier, or what? I am trying to make an IF/THEN statement so that the dialogue box only shows up if a match is not found, but it is erroring out as I have it written and the message does not make sense to me. [CODE] … Re: Searching a Text Field in a JList Programming Software Development by TheGathering To be more specific, change: [code] if(cdNameField.getText().equalsIgnoreCase(s)) { Inventorylist.setSelectedIndex(i); Inventorylist.scrollRectToVisible( Inventorylist.getCellBounds(i,i) ); // do the stuff below boolean here break; else JOptionPane.showMessageDialog(null,"No CD Match Found&… Re: Searching a Text Field in a JList Programming Software Development by Ezzaral [quote=no1zson;413889]sorry. :$ It is the only way I have found that I can make sense of most of this. Until I see it down in code, and can see how information flows through what is written, see how the input and output works, then it is just words on the screen. It is one of the reasons I have such problems with the API I think. I have not …