Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Sorry, no personal experience parsing hex, but maybe this info could be helpful:
http://mindprod.com/jgloss/hex.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You will want to call the start() method to begin thread execution instead of calling run() directly. Start() sets up other necessary things and then calls run(), which is why the Runnable interface requires you to override run() to provide the actual "what am I supposed to do" part of the thread.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I was playing around with a timer-based key processor and I think you are going to have issues with key listener. Here is the processor I wrote

class KeyProcessor extends javax.swing.Timer {
    List keyQueue = new ArrayList();

    final static int KEY_1 = KeyEvent.VK_A;
    final static int KEY_2 = KeyEvent.VK_B;

    public KeyProcessor(int delay, ActionListener listener) {
        super(delay, null);
        addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                if (keyQueue.contains(KEY_1) && keyQueue.contains(KEY_2))
                    lblState.setText("State A+B");
                else if (keyQueue.contains(KEY_1))
                    lblState.setText("State A");
                else if (keyQueue.contains(KEY_2))
                    lblState.setText("State B");
                keyQueue.clear();
            }
        });
    }

I then started that up and attached a KeyListener to feed the key queue

keyProcessor = new KeyProcessor(200,null);
txtInput.addKeyListener(new KeyAdapter() {
    public void keyPressed(KeyEvent e){
        keyProcessor.queueKey(e.getKeyCode());
    }
});
keyProcessor.start();

It will process the A+B state fine just once if the key combo comes in within the time slice, but if the keys are held down then only the last key pressed gets repeated, so the state will change either A or B. Now, I am running this on a Windows XP machine so maybe it's a system specific thing with how repeated keypresses are handled, but it is obviously an issue on Windows.

I haven't had to do anything like this with KeyListeners before, so maybe there is some other technique to listen for both of those keys, but keyPressed() isn't receiving both key code.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well acctualy I'm clueless with threads, I just happen to be using one off a tutorial for my animation. I guess at this point I just have to do some research on threads. By the way do you think 50 is faster than humanly possible to double tap a key?

Not sure, System.out.println(System.currentTimeMillis() - lastTime) is a decent way to find out though.

If you have the time, mind answering this question...

I was following this example: ( http://www.javaworld.com/jw-03-1996/animation/Example1Applet.html ) and what confuses me is the start function. Being that the new thread is "this" and in the start function, start is called in the new thread; how's that not a looping effect?

Yes,I can see where it would be a bit confusing in that both threads and applets have start() methods. In the applet start() method, they are creating a new Thread with the constructor Thread(Runnable target) . Because they have defined the applet to implement the Runnable interface and provided a run() method in the class, they can pass the class object "this" to the Thread constructor. They then start that thread running with the animator.start() call. The fact that it was done in the applet start() method does make it a bit awkward to read if you aren't used to threads.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I'd say yes, you're probably going to have to deal with threads for that. It sounds like you have a decent handle on how to proceed with it via the KeyInterpreter. If you queue the received keys and process them in a timer event you can dispatch to the appropriate actions. Of course, tuning that dispatch to prevent lagging of the individual A and B actions or allowing the transitions such as A to AB or B to AB may be the tricky part.

It sounds like the transition states are what you are wanting to avoid, so I would think if you keep the timer event short enough you can dispatch to the appropriate method based on the queued keys.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Thanks for that will try it out in the next few minutes.
By implication of your comment I would be better off going back and restarting and creating each of the GUI displays in its own individual frame.
Would my code be along the correct lines to get the mainMenu up on the screen if I were to start again and give each display its own display.

It just depends on how you wish your app to behave. If you need to maintain several documents and panels open at the same time, but need them constrained in a single parent frame, then stick with the JDesktopPane. On the other hand, if you are primarily working from one frame at a time or wish to have the ability to maximize multiple frames on different monitors, you are better off with regular JFrames. On my current project, most users have 3 monitors and prefer individual components that they can organize as they please without the limit of a single desktop container frame. So it's a matter of how you want to present the components to the user. If it's a single screen app for the most part, you certainly won't need a desktop pane.

I presume that if i were to do this that the LogOn (being the first display) would be the only one to have a main()
Thanks for the help

Yes, the login would be the entry point with a main method. On successful login you …

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You probably need to add the menu frame to the desktop pane such as in this code fragment

protected void createFrame() {
    MyInternalFrame frame = new MyInternalFrame();
    frame.setVisible(true);
    desktop.add(frame);
    try {
        frame.setSelected(true);
    } catch (java.beans.PropertyVetoException e) {}
}

Is there a particular reason you need to use the JDesktopPane and internal frames, instead of standalone JFrames?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, it won't wait but you can keep track of it for yourself with something like this

// class level
long lastKeyPress = System.currentTimeMillis();
int lastKey=0;
// whichever keys you need
final static int KEY_1 = KeyEvent.VK_A;  
final static int KEY_2 = KeyEvent.VK_B;
// whatever interval you need for "at the same time"
// 50ms seems to work ok
final static int TIME_LIMIT = 50;

// wherever you set up the KeyListener
component.addKeyListener(new KeyAdapter() {
            public void keyPressed(KeyEvent e){
                if (System.currentTimeMillis() - lastKeyPress < TIME_LIMIT && ((lastKey|e.getKeyCode())==(KEY_2|KEY_1)) ){
                    // within time limit
                    doSpecial();                        
                }

                lastKeyPress = System.currentTimeMillis();
                lastKey = e.getKeyCode();
            }        
        });
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You might change the default 'any' value for houseplans on the form to ""

<option selected="selected" value="">All Types</option>

so that they are all consistent and try this

$plantypes = ($_POST['houseplans']) ? $_POST['houseplans']):'%';
$bed  = ($_POST['bedrooms']) ? $_POST['bedrooms'] : '%';
$bath = ($_POST['bathrooms']) ? $_POST['bathrooms'] : '%';
$garage  = ($_POST['garages']) ? $_POST['garages'] : '%';

. This will set the variable to its selected value if it's not null or '%' for the null case. Then change the query to

$query = sprintf("SELECT PLANNO, PLANTYPES, DESC, BED, BATH, GARAGE, FLOORS, URL, IMG FROM plans WHERE PLANTYPES like '%s' AND BED like '%s' AND BATH like '%s' AND GARAGE like '%s'",
   mysql_real_escape_string($plantypes),
   mysql_real_escape_string($bed),
   mysql_real_escape_string($bath),
   mysql_real_escape_string($garage));

The sprintf() function still needs the '%s' for the variable substitution. From the docs, it sounds like the LIKE '%' wildcard should work with numerics, but I have not verified that myself. It it does not, you will have to build the WHERE string dynamically by concatenating those pieces that have a value other than "" (which was "any").

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ah, the syntax error is because DESC is a reserved word, you'll have to escape that with `desc` I think. You will also need to handle the "any" cases as well, perhaps by changing the use of = to LIKE (i.e. BED LIKE '%') and use the % wildcard for the "any value" cases.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I would recommend changing your form method to 'post' instead of 'get' and then you just need to pull the variables in from the $_POST[] array and you should be good to go. I think you want to do this

//variables from submit form
$houseplans = $_POST['houseplans'];
$bedrooms  = $_POST['bedrooms'];
$bathrooms = $$_POST['bathrooms'];
$garages  = $_POST['garages'];

and change your sql parameters to use those variables.

If you want to stick with GET for your form method, just change the $_POST refs to $_GET.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

yes i have copied the .jar files in WEB-INF/lib but still when i have compiled database connectivity program with mysql in java it gave the same error.

D:\Program Files\Java\jdk1.5.0\bin\java.exe ConnBean
Working Directory - C:\final project\jsp code\
Class Path - .;c:\Kawapro5.0\kawaclasses.zip;d:\program files\java\jdk1.5.0\lib\tools.jar;d:\program files\java\jdk1.5.0\jre\lib\rt.jar
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

....

Why are you trying to run the ConnBean from the jdk bin folder if you wish to access this through Tomcat? If you want to run from the command line, you need to specify the classpath. Many posts have told you how to do that. If you have a JSP/servlet app running in Tomcat that needs that ConnBean, then placing the jar in WEB-INF/lib for that app is all that you need to do.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I would imagine the technical support forums at World of Warcraft do.

This forum is just general game development questions. You would get much more specific help asking on the WoW tech forums as they are much more familiar with their own products.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

This free, online book is another handy reference for learning java. It doesn't cover some of the latest additions to the language but it is still valid (and free!) :
Thinking In Java, 3rd Edition

http://www.smart2help.com/e-books/tij-3rd-edition/TIJ3.htm

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If you use foreach() you won't even need to bother with the indexing.

<?php
$list[] = "first";
$list[] = "second";
$list[] = "third";

foreach ($list as $entry){
  mail($entry, "Hey", "Whats up?");
}
?>
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

So?

I learned Java just so I knew at least one, non-Smalltalk-based, OOP language.

I'm still making use of other classes within the program (javax.swing.JFrame, javax.swing.JButton, etc.). I don't see what the big deal is. And my take on that algorithm is *not* avoiding the "point" of OOP. I'm providing a clean, readable program that works.

At least you aren't touchy about a suggestion.:-O
Your program certainly does work, it just demonstrates a methodology that a beginner may learn some bad habits from. Making everything static and calling it directly from main() is not a good standard practice.

And thank you for clarifying what main()'s purpose is in this world - here I am thinking it's just some useless, needed function. *rolls eyes*

Well, evidently you do need some clarification, so roll your eyes all you wish - it doesn't make it correct. main() should not directly call state-dependent methods directly inside a class. It should generally be used in a manner like an external driver program to initialize the object and utilize the public methods of that object. The object itself should handle any necessary internal interaction.

I think it's stupid to instantiate a class from within itself.

The object has to come from somewhere. Java only runs .class files and objects don't just pop into being on their own. You shouldn't really think of main() as being part of a class, but rather an entry point to running that class. Use main to set it …

iamthwee commented: Spot on. +9
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Actually, making every method static and running the whole thing through main() is just making a procedural program and misses the whole point of OO. Main should only be used as an entry point to set up the needed class(es).

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Thanks for replying to my question. Adding a "try again" button is a good idea, but I'm restricted to a certain design consisting of : one text field, two labels and only one button. Thanks again!

That's fine. Keep a counter of the number of tries, increment when user hits your button to compare a guess, and when they hit five tries it's over. You really don't even need a loop for anything at all.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I assume you are wanting the user to get 5 guesses at the number before ending. This isn't really what your loop is doing though. It is evaluating the same input 5 times (or less if they got it right) and then exiting.

int n = Integer.parseInt(t.getText());

will not wait for input from the user line a Scanner.nextInt() would. It just reads that field each iteration and keeps going. You will need to move the loop up to a different method (like a "Try Again" button handler) that allows them to enter up to 5 guesses before begin disabled. You could leave the the compare code in your method if you like, but you will need the loop to be separate so that you only read new input when they hit the button (or press enter if you want to use an ActionListener on the test field).

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I think it would help if "graybies" counted for a point or two. Out of over 300 posts in Java and PHP, many of my rep comments come from new users to just say "Thanks, that helped". Honestly, it's nice enough just to get the comment, but if those counted just a bit then rep would creep up as help was meeted out.

I read some of the Gray Reputation thread so I understand why it's the way it is, but it seems a mere point or two wouldn't foster "rep wars".

Just my thoughts. I'm fairly new and just help out with the tech questions for the heck of it, so I'm not really inclined to sweat it either way.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

So are you hinting that I could possibly use currCD to set this value, with little change since it is already coded and working?

I thought about trying something like that, when I started looking at putting key++ in my add button code, but was worried about using the same counter for two different things. Thought that might create some kind of problems somewhere.

You are only using it to set an item number property on the object. That won't affect your usage of currCD as the pointer to the current list position at all.
listModel.add() adds the item to the end of the list, thus the index of the last items increases by one automatically. You are just capturing that value and saving it to the item id property. You could set it to (currCD+1) if you don't want zero based item ids.

Since you are not using that value to access anything anyway, it doesn't matter what the number is as long as it's unique in the list. A simple int itemCounter and a setItemId(++itemCounter) would work just as well.

peter_budo commented: Nice explanation +5
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You might check your usage of the strstr() function, it may be a simple typo or something. The following works fine for me.

<?php
$s = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.12) Gecko/20070508 Firefox/1.5.0.12";
echo ($found=strstr($s,"Firefox")) ? $found : "(not found)";
echo "<br>Firefox position: ".strpos($s,"Firefox");

echo "<br>Firefox removed..<br>";

$s = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.12) Gecko/20070508 /1.5.0.12";
echo ($found=strstr($s,"Firefox")) ? $found : "(not found)";
echo "<br>Firefox position: ".strpos($s,"Firefox");
?>

preg_match() is always an option if you need more complicated parsing.

Edit: The above was just a knock-up test demo - not my suggestion for code to check browser type :)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Keep in mind, you already set currCD to the last index of the list model after you add it - and that index position is unique.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I don't see anywhere that you have initialized an instance of your key generator, unless you have that elsewhere in the code. You'll have to create one before you can call it.

Using a separate class with an extra interface is a bit of overkill for what you are needing here, but it will work if you want to stick with that. I would change the variable names to something that makes sense to you, such as getKey() instead of give().

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ez-
That is not entirely true. I do not replace any code without thinking it through. The problem for me is that, besides here, I have absolutley NO instruction on how to do any of this. A month ago I did not even know what a method was...

My apologies for the particular choice of words.

Glad you got it to work. A couple of suggestions:

// SAVE        
        private void btnSaveActionPerformed(ActionEvent evt)
        {
            // use variable names that have meaning in your context
            File dataDir = new File("C:" + File.separator + "data");
                    
            try
            {
                if( !dataDir.exists() )// shorter expresion with ! operator
                {
                   dataDir.mkdir();// make directory
                   // toWork.createNewFile();  // create file (don't need)
                }
                if( !dataDir.canRead() ) 
                    System.out.println("Read Error.");
                if( !toWork.canWrite()) 
                    System.out.println("Write error.");
                }
                
                catch (Exception e){
                 // generally not good to catch exceptions and do nothing
                }   

                
            FileOutputStream out; // declare a file output object
            PrintStream p; // declare a print stream object
            
            try
                {
                // create a new file output stream
                // connected to "inventory.dat"
                // can use dataDir here and just append file name
                out = new FileOutputStream(dataDir + File.separator + "inventory.dat");
                
                // connect print stream to the output stream
                p = new PrintStream(out);
                
                p.println (listModel);
                p.close();
               }
               catch (Exception e)
                {
                  System.err.println ("Error writing to file");
                }    
                
        }// end SAVE

Have you looked at the output in your data file yet? It might not be what you expect because the entire listModel.toString() is being dumped to the println() method. You may want to …

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

1) "Then answer is: no"

Yes, 1 is correct.

2) public int factorialSum()
{
int factorial =a;
int factorial =b;
factorialSum=a+b;
return;
}
Is it right? Thank you

Your assignment indicates that you need to calculate the factorial of each number and then add them. You are only adding them. Also, factorialSum is not defined in your method, you are not returning anything, you have not checked to make sure the parameters are valid, and the method does not print the result to the console as requested. You have a start, but more to do here.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Hello

I did not ask to write code to me at all. I already wrote mine,but I have doubts about correctness. Thank you

Then post it within code tags with any questions you have about it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

the elseif needs to be inside in front of the condition, you have it on the line below in front of a string for your img tag (which also won't work right). Also, you've gotten your php code and html tangled up in the last couple of cases. Check your php tags.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Sorry, no one is going to do the homework for you. Post code you are having trouble with or specific questions about what you don't understand if you want any assistance.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

OK, with the fileoutput stream I was able to write the file, but not create the directory.

Use a separate File object for the directory. Java treats files and directories both as File.

With the new File statement I am able to create the directory but not write the file.

Your code wrote to the console - just like you told it to.

System.out.println(listModel);

I assume you are working from a class example, but you are replacing crucial pieces with chunks of example code here with no thought to what they are actually doing.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Tried that before, didn't seem to help, I'll give it another bash, changed a few things since then, cheers

You haven't really said what "won't work" means in this case. No results? Wrong results? Error messages?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

"java -version" from the command line or System.getProperty("java.specification.version"); From the docs on this system property

The requirement to identify the Java Runtime is already partially met via the properties specified by the Java Language Specification, §20.18.7 using java.lang.System.getProperties.

  • java.version i.e. Solaris 1.2
  • java.vendor i.e. Sun Microsystems Inc.

Currently these identify the implementation of the Java runtime and the core classes that are available. These properties do not identify the Java Language Specification version that this JDK implements.
Additional properties are needed to identify the version of the Java Runtime Environment specification that this implementation adhere’s to. The properties are:

  • java.specification.version i.e. 1.1
  • java.specification.name i.e. Java™ Language Specification
  • java.specification.vendor i.e. Sun Microsystems Inc.

These properties are accessed using the method java.lang.System.getProperty and return their values as strings.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I would like to secure file access, can you point me in the right direction? Thanks Dave

If you are using Apache then .htaccess will allow you to control that. Here are a couple of tutorials:
http://httpd.apache.org/docs/1.3/howto/htaccess.html

http://www.javascriptkit.com/howto/htaccess.shtml

http://articles.techrepublic.com.com/5100-6347_11-5034311.html

Dsiembab commented: thanks appreciate it +1
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

See comments in the code (prefixed Ez).
This should be a working version, but I just banged it out in a text editor real quick so any syntax errors are yours to enjoy. I also didn't bother changing a couple of things that would make it slightly more efficient (like holding on to the reference of the found CD instead of getting it again) because I didn't want to induce even more confusion over the mechanics.

//start at first cd
//currCD = 0;    // Ez: removed, this has nothing to do with the search

// compare
//JTextField f = searchField;  // Ez: also removed, superfluous
final String searchString = searchField.getText(); 

SwingUtilities.invokeLater( new Runnable() 
{ 
    public void run() 
    { 
        boolean matchFound=false;    // Ez: this is a simple boolean flag for whether match found
        for(int i = 0; i < listModel.getSize();  i++) 
        { 
            CdwArtist cdEntry = (CdwArtist)listModel.elementAt(i);
                    
            if(cdEntry.getName().equalsIgnoreCase(searchString))     // Ez: Yes, you were comparing the cdname field against the search field
            { 
                matchFound=true;
                currCD = i;
                break;
            }
        } 
        // Ez: All you have to do now is check the match flag
        if (matchFound) {
            Inventorylist.setSelectedIndex(i); 
            Inventorylist.scrollRectToVisible( Inventorylist.getCellBounds(i,i) );
        
            CdwArtist newCD = (CdwArtist) listModel.get( currCD );
    
            artistField.setText(newCD.getArtist());
            cdNameField.setText(newCD.getName());    
            itemField.setText(String.valueOf(newCD.getItemno()));
            nstockField.setText(String.valueOf(newCD.getNstock()));
            priceField.setText(formatter.format(newCD.getPrice()));
        }
        else
        {
             // Ez: No match
            JOptionPane.showMessageDialog(null,"No CD Match Found","TryAgain",JOptionPane.INFORMATION_MESSAGE); 
        } 
    } 
});
no1zson commented: Best poster out here. Paitence of 10 people. +1
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It sounds like you are talking about securing file access - not screen scraping.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

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 seen enough Java to even know how to structure things properly yet, the code frags help with my logic.

I know my stuff is not clean, or probably not even acceptable to most standards with now, but this is the most effective way I have found to learn.

That was only in reply to peter's apology :) With all the pieces of code flying around it's easy to see where he might have thought that was my code fragment.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

My appology then :)

hehe... no worries, there are a lot of code fragments floating around here.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

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 :).

Actually those variables came from the code sample he got elsewhere for a CaretListener (shown in first post). I wouldn't use those if I were writing an example myself :)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

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?

JTextField f = (JTextField)e.getSource(); 
            final String s = f.getText();

f, is this really just my searchField? I cannot figure out why there is an f there or what it means.

Those are variables - from the code that you copied and pasted in from a method that had a parameter "e". The others are defined right there in the method. Rename them whatever you want - they are variables.

I know e.getSource() should be replaced with what I am looking for, ie my cdNameField text, and string s, I cannot figure out what s is supposed to be.
I keep wanting to change it to

JTextField searchField = (jTextField).cdNameField
final String ??? = searchField.getText();

but of course that does not mean anything.

You are correct - that doesn't mean anything. The original code was doing nothing more than defining a String variable (which they called "s"; name it whatever you like) with the contents of a text field, which is the String that you want to search for.

second question is cdEntry.

CdwArtist cdEntry = (CdwArtist)listModel.elementAt(i);

Where did that come from, and why do I need it here?

Well, you do want to check a field on an item in the list, right? To do that you have to have a reference to it, hence the reference.

If …

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

you mean like chmod or .htaccess, I guess I'll have to read up on perl. thanks anyways

No, I mean that if your script is sending any output to a user at all (html, text, whatever), that user can scrape it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

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.

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 changed "String item" to "CdwArtist cdEntry", so you have to work with the cdEntry now (and it has method to get it's properties...).

The only problem with your message box is a missing parameter. The form you are trying to use takes four, not three, which I am sure the compiler yelled at you about.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Is their a way to prevent screen scraping? Thanks Dave

Only one that I know of: don't produce any output.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You already had a pretty good start on the searching in that first post. The only issue there is that instead of

String item = (String)listModel.elementAt(i);

you would instead want to get

CdwArtist cdEntry = (CdwArtist)listModel.elementAt(i);

Using a boolean such as "matchFound" which is flagged on a match, you can present the message dialog if there was no match.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, for all that I loathe Bush and what this administration has done, I am not aware of any law which he has broken - except those of trust, responsibility, and decency.

If there are specific criminal charges outlined, then they could impeach them, but short of that it's all just a lot of arm-waving.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

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 really can't spell it out any more clearly than that short of writing the code myself.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

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: if (searchField == cdNameField);

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

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 that the current cd. If there is no match, you could use the JOptionPane.showMessageDialog() method to inform the user that no match was found (alternately a label under the search field could be used for that as well).

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

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.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

1st - This listener seems to be a CaretListener .... how will that work with my ActionListener and my SEARCH button?

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 variable like boolean searching; for the caret listener to check before performing the search. Alternately you could provide a separate search field for the user to type in or use an input dialog (JOptionPane.showInputDialog(..) ) for this. It depends on how you want searching to be performed.

2nd - I already have a runnable for my panel. Does the code from this runnable next inside my current one, or can I have more than one in the same app?

You can have multiple runnables just fine. All those are doing is putting a piece of code into a queue to be run in a separate thread.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Classpath can also be set as a parameter in the javac command with the -cp (or -classpath) switch

javac -cp .;%CLASSPATH%;c:/myProject/lib/aJarFile.jar myProgram.java