ListSelectionListener does nothing

I have a JList with some names of people in it that gets pulled from a database, when I click the names I want information to be put into a text area. When I click on a name currently, nothing happens.
here's my code:
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.sql.*;
import java.util.*;
public class Gifts extends JFrame
     static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
     static final String DATABASE_URL = "jdbc:mysql://localhost/test?user=root&password=root";
   private JList nameList;
     private JTextArea statList;
     private JButton add;
   private Container container;
     private JPanel nameListPanel, statListPanel, buttonPanel;
     private Connection conn;
     private Statement stat;
   public Gifts()
          super( "Spiritual Gift Database" );
          try
               Class.forName(JDBC_DRIVER);
               conn = DriverManager.getConnection(DATABASE_URL);
               stat = conn.createStatement();
               ResultSet rs = stat.executeQuery("SELECT heading1 FROM demo");
               Vector vector1 = new Vector();
               while(rs.next()) vector1.add(rs.getObject(1));
               container = getContentPane();
           container.setLayout( new FlowLayout() );
               nameListPanel = new JPanel();
               statListPanel = new JPanel();
               buttonPanel = new JPanel();
           nameList = new JList(vector1);
           nameList.setVisibleRowCount( 9 );
               nameList.setPrototypeCellValue("XXXXXXXXXXXX");
               nameList.addListSelectionListener(
                    new ListSelectionListener()
                         public void valueChanged(ListSelectionEvent event)
                              try
                                   ResultSet resultSet = stat.executeQuery("SELECT * FROM demo");
                                   StringBuffer results = new StringBuffer();
                                   ResultSetMetaData metaData = resultSet.getMetaData();
                                   int numberOfColumns = metaData.getColumnCount();
                                   for(int i = 1; i<=numberOfColumns; i++)
                                   results.append(metaData.getColumnName(i) + "\t");
                                   results.append("\n");
                                   while (resultSet.next())
                                        for(int i = 1; i<= numberOfColumns; i++)
                                        results.append(resultSet.getObject(i) + "\t");
                                        results.append("\n");
                              catch(SQLException sqlException)
                                   JOptionPane.showMessageDialog(null,sqlException.getMessage(),
                                   "Database Error1", JOptionPane.ERROR_MESSAGE);
                                   System.exit(1);
               statList = new JTextArea(10,20);
               add = new JButton("Add Entry");
           nameList.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
               statListPanel.add(new JScrollPane(statList));   
           nameListPanel.add( new JScrollPane(nameList));
               buttonPanel.add(add);
               container.add(nameListPanel, BorderLayout.EAST);
               container.add(statListPanel, BorderLayout.WEST);
               container.add(buttonPanel);
           setSize( 400, 300 );
           setVisible( true );
          }//end try block
          catch(SQLException sqlException)
               JOptionPane.showMessageDialog(null,sqlException.getMessage(),
               "Database Error1", JOptionPane.ERROR_MESSAGE);
               System.exit(1);
          catch (ClassNotFoundException classNotFound)
               JOptionPane.showMessageDialog(null, classNotFound.getMessage(),
               "Driver Not Found", JOptionPane.ERROR_MESSAGE);
               System.exit(1);
     }//end Gifts()
   public static void main( String args[] )
      Gifts application = new Gifts();
      application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
}

In you valueChanged method, "results" never gets added (appended) to "statList". Definately nothing will show up.
ICE

Similar Messages

  • I am trying to install a language disc. I clicked on the installer. It ran for a long time without installing. I click stop installing and it says it is stopping but is doing nothing. I am unable to eject the disc or stop anything.

    I am trying to install a Portugese language disc. I clicked on the installer icon and it said it was installing, but it ran forever without doing anything. I clicked "stop installing" and it says "stopping", but it is doing nothing. I am unable to eject the disc or do anything because it says an operation is in progress.

    Please provide some info on the disc, where it comes from, who made it, etc.  Also tell us what version of OS X you are running.

  • I upgraded from 3.6.13 to Beta 4.0 and now Firefox will not open at all I tried to uninstall to start again but it will not uninstall either it does nothing.

    I uninstalled Beta 4 and re-installed 3.6.13 now Firefox will not open at all I tried to uninstall to start again but it will not uninstall either it does nothing, I have been using Firefox for a long time but cannot resolve this problem can anyone help and give me a solution please. As I use Firefox as my web browser it is very frustrating.
    The fact it will not uninstall appears to be something completely new as nobody I know who uses Firefox has ever encountered this in the past.

    Did you check your security software (firewall)?
    A possible cause is security software (firewall) that blocks or restricts Firefox without informing you about that, possibly after detecting changes (update) to the Firefox program.
    Remove all rules for Firefox from the permissions list in the firewall and let your firewall ask again for permission to get full unrestricted access to internet for Firefox and the plugin-container process.
    See [[Server not found]] and [[Firewalls]] and http://kb.mozillazine.org/Firewalls
    If necessary then also see:
    * http://kb.mozillazine.org/Browser_will_not_start_up
    * http://kb.mozillazine.org/Error_loading_websites

  • Trying to do a software update, but my macbook pro does nothing after it prompts me to restart

    I am trying to do a software update on my Macbook Pro so I can update the new iTunes so I can start using my new iPod. Every time I go through the process of the computer searching for updates and confirming there are software updates, then being prompted to restart my computer, it does nothing. After my Macbook Pro turns on again, nothing pops up and I go into my information and it says I still have the old software. Nothing is prompting me to do the update after I restart my computer, or beforehand for that matter. HELP.

    Are you really still running 10.6.2? If Software Update isn't working for you, you may want to try using the 10.6.8 combo update found here -->> http://support.apple.com/kb/DL1399.
    If that doesn't work, call back...
    Clinton

  • Why does my itunes crash after start up with an "APPCRASH" error every time i open it?! I have been trying to fix this for weeks but all i can do it re-install it every other day which does nothing!

    Why does my itunes crash after start up with an "APPCRASH" error every time i open it?! I have been trying to fix this for weeks but all i can do it re-install it every other day which does nothing! I am desperate to get access to my itunes to get music on my phone and all of this just makes me want me to sell my iphone since there is no other way to add music to my phone. If things go get sorted soon you can say goodbye to my support.

    For general advice see Troubleshooting issues with iTunes for Windows updates.
    The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down the page in case one of them applies.
    The further information area has direct links to the current and recent builds in case you have problems downloading, need to revert to an older version or want to try the iTunes for Windows (64-bit - for older video cards) release as a workaround for installation or performance issues, or compatibility with QuickTime or third party software.
    Your library should be unaffected by these steps but there are also links to backup and recovery advice should it be needed.
    tt2

  • My 4S has stopped ringing. Voicemail's disabled but if you call me, you'll hear it ring your end but it does nothing at mine and freezes if I make a call. Texts are not being delivered or coming through delayed. Ringer is on, tone enabled - help!

    My iPhone 4S has stopped ringing altogether. Voicemail is disabled but if you call me, you'll hear it ringing at your end but it does nothing my end and freezes in the phone app if I make a call (doesn't ring or connect and doesn't freeze the phone, just the calling part). Texts are not being delivered or coming through delayed. Ringer is on, tone enabled - help!
    I've disabled roaming so it only runs on wifi (this after getting a £4k phone bill...) and I can use Skype, Viber and WhatsApp with no problem at all.
    Would really appreciate any help at all!
    Many thanks.

    Hi there - am with Orange and they said nothing wrong with account and service running normally.  They said if they had cut me off I would've received a text (debatable with current message receiving situation!) and when I called out it would say 'calls from this number are barred'.  Also if you called me it would say something similar.  But it doesn't, it will ring and ring until it rings off but nothing happens at all on my handset. Not even a missed call notification.  If I call out, it will display that it is calling the number but that's it.  If I cancel the call it will constantly display 'ending call'.  If I come out of the phone and go to another app then revist phone it will start calling that last dialled number - without ever getting as far as ringing or connecting.

  • When trying to PDF a webpage into a PDF, it does not work, I go through all the steps as normal, and It does nothing. I can repeat my action, where instead of "printing" to adobe, it saves the file, which it doesn't save it at all. I can't even find the o

    When trying to PDF a webpage into a PDF, it does not work, I go through all the steps as normal, and It does nothing. I can repeat my action, where instead of "printing" to adobe, it saves the file, which it doesn't save it at all. I can't even find the original in my work folder. I need to know how to stop this from happeing and get it back to the way it has been working he last 6 months since i purchased this program.

    Hi pissedadobeuser,
    Does this issue occur with any particular web page?
    Are you able to print the webpage to 'Adobe PDF' to convert it to pdf.
    Which Browser version, OS version and Acrobat version are you using?
    Regards,
    Rave

  • How do i close the welcome to iMovie screen? Clicking on red button in upper left does nothing. SOS!  Thanks!

    How do I close the "Welcome to iMovie" screen?  Clicking on the red button in the upper left does nothing. SOS!  Thanks!

    "Continue" was hidden at the bottom of the welcome screen because my display was changed.  Some days I'm smarter than others.  Or.... :-) 

  • After a firefox "upgrade" was installed automatically, Firefox will not start, even in Safe mode. Clicking on the icon does nothing

    after a firefox upgrade was auto-installed, firefox no longer will launch. clicking on the icon does nothing. can't start in safe mode
    == This happened ==
    Not sure how often
    == firefox upgrade auto-installed ==
    == User Agent ==
    Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10

    You can try to disable the Java Quick starter and the Java Console extension in the Control Panel > Java.
    Control Panel > Java > Advanced tab > Miscellaneous >Java Quick Starter (disable)
    You can also disable the Java plugin in Firefox: Tools > Add-ons > Plugins
    See [[Troubleshooting extensions and themes]]
    See [[Troubleshooting plugins]]

  • Clicking on link in dynamic document does nothing

    Hello my friends,
    I Add link to my dynamic document but when I press on the link it does
    nothing. I create event handle class and connected it to the link and
    it still did not work.
    Please help me if you can, its urgent.
    Regards,
    Eitan Iluzz.

    Try this: http://helpx.adobe.com/creative-cloud/help/launch-creative-cloud-apps.html

  • Clicking on the bookmark toolbar does nothing

    Clicking on the bookmarks in the bookmark bar does nothing. However, when I right click, I can open the bookmarks, selecting either open, open in new window, or open in new tab.
    I don't know if this is related, but clicking the "Add tab" button does nothing as well.

    hello, one of your addons might be interfering - try if it's working correctly when you launch firefox in safemode.
    [[Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems]]

  • The search function in the itunes store does not work.  It will accept a request and suggest searches but then it locks up and will not search.  Clicking on the magnifying glass or a suggested search does nothing.  Re-installing itunes has not helped.

    The search function in the itunes store does not work.  It will accept a request and suggest searches but then it locks up and will not search.  Clicking on the magnifying glass or a suggested search does nothing.  Re-installing itunes has not helped.

    everything you stated here is exactly what i have done and have got nowhere. i have windows 7 64 bit on a hp 8 g of ram desktop. im also looking for help

  • Clicking on M/S' RUN and/or SAVE does nothing - just sits there

    Have had this problem for a few days. In trying to open again, it always tells me Firefox is still running and to close it first. There is no Firefox running! Have uninstalled FF and in trying to install a new one, I get as far as the Run/Save; clicking on either one does nothing, it just sits there. Thanks for your help. PS - I've been using FF for ages - first time I've had this problem. PPS = tried to cut/paste browser url but went to open a file.

    Certain Firefox problems can be solved by performing a ''Clean reinstall''. This means you remove Firefox program files and then reinstall Firefox. Please follow these steps:
    '''Note:''' You might want to print these steps or view them in another browser.
    #Download the latest Desktop version of Firefox from [https://www.mozilla.org mozilla.org] (or choose the download for your operating system and language from [https://www.mozilla.org/firefox/all/ this page]) and save the setup file to your computer.
    #After the download finishes, close all Firefox windows (or open the Firefox menu [[Image:New Fx Menu]] and click the close button [[Image:Close 29]]).
    #Delete the Firefox installation folder, which is located in one of these locations, by default:
    #*'''Windows:'''
    #**C:\Program Files\Mozilla Firefox
    #**C:\Program Files (x86)\Mozilla Firefox
    #*'''Mac:''' Delete Firefox from the Applications folder.
    #*'''Linux:''' If you installed Firefox with the distro-based package manager, you should use the same way to uninstall it - see [[Installing Firefox on Linux]]. If you downloaded and installed the binary package from the [http://www.mozilla.org/firefox#desktop Firefox download page], simply remove the folder ''firefox'' in your home directory.
    #Now, go ahead and reinstall Firefox:
    ##Double-click the downloaded installation file and go through the steps of the installation wizard.
    ##Once the wizard is finished, choose to directly open Firefox after clicking the Finish button.
    More information about reinstalling Firefox can be found [[Troubleshoot and diagnose Firefox problems#w_5-reinstall-firefox|here]].
    <b>WARNING:</b> Do not use a third party uninstaller as part of this process. Doing so could permanently delete your [[Profiles|Firefox profile]] data, including but not limited to, extensions, cache, cookies, bookmarks, personal settings and saved passwords. <u>These cannot be easily recovered unless they have been backed up to an external device!</u> See [[Back up and restore information in Firefox profiles]]. <!-- Starting in Firefox 31, the Firefox uninstaller no longer lets you remove user profile data.Ref: Bug 432017 and https://support.mozilla.org/kb/uninstall-firefox-from-your-computer/discuss/5279 [Fx31] Windows uninstaller will no longer offer the option to remove personal data -->
    Please report back to say if this helped you!
    Thank you.

  • Clicking on "order prints" just says "connecting" then does nothing ...

    I fear that I screwed up somewhere in setting up my 1-click setting and now when I select a photo and click on order prints, it just says connecting then does nothing. It doesn't even take me to the 1-click screen to allow me to change account info. Does anyone know of a way to at least get me back to the 1-click page to allow me to associate my mac account to iphoto?

    Hi bplatinum,
    http://docs.info.apple.com/article.html?artnum=303168
    This Apple kb says to reinstall iPhoto 6. Hopefully that will solve it for you.

  • Just bought new iMac. When browsing in Safari, sometimes the text suddenly gets super large. I'm doing nothing except reading the screen, tho I have my hand on the mouse. I can get back to normal size by clicking "actual size" in View. What gives?

    Just bought brand new new iMac. When browsing in Safari, sometimes the text suddenly gets super large. I'm doing nothing except reading the screen, tho I usually have my hand resting lightly on the mouse. I can get back to normal size by clicking "actual size" in View. But then it does it again a minute or two later. What gives? Something seems defective--but what?

    From System Preferences, Mouse, Point & Click, Secondary click.  Go to it hover over Secondary click and watch the short video sequence change it left right, left right, you will see exactly what is does. No I do not think your Mouse is defective, you simply need to take control of your Mouse finger.

Maybe you are looking for

  • Need to add print and download options for report in new window

    Hi, On one of the columns empid of the report1 (which is on the dashboard) , I am using navigation and pointing it to report2. Report1 has all the links, print, download and refresh (I enabled them using the section properties) but when I click on em

  • Purchase order changes through EDI

    Hi All, Is it possible to transmit only changes made againt each purchase order through EDI. If so how that can be done. For example if the quanity of purchase order changed then only changed quanity field should be transmitted through EDI. Thanks &

  • Customer stock  reset -- sales order deleted.

    Hi Gurus, customer stock tied to the sales order is updated. But now the sales order is deleted. Now, How to remove the material form customer stock. Thanks in advance ram

  • New to XI, pls pls help

    Hi all, I am completely new to XI. The scenario which needs to implemented is as follows -> We have a .net Application which needs to push and pull some data in SAP R/3 using XI. I have an option of using either a file adapter or a SOAP adapter in XI

  • Why increase  sysaux tablespace

    Hi Experts, I have a bi-direction oracle 10GR2 stream in window 2003. I got a error message in alert. error 12801 in STREAMS process ORA-12801: error signaled in parallel query server P000 ORA-01653: unable to extend table SYS.STREAMS$_APPLY_SPILL_ME