Problems adding to a JList

in my filter panel i have a text field, and a search button. when i enter some text and click search, the text should appear in the JList. but all that happens is the test field clears (which should happen) but doesnt appear in the JList. here is my code below:
firstly for the setting up of the JList:
          //the JList with a model, renderer and selectionListener
          filterListModel = new DefaultListModel();
          filterList = new JList(filterListModel);
          filterList.setCellRenderer(new CustomCellRenderer());
          filterList.addListSelectionListener(new MyListSelectionListener());
          filterList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);then the action performed for the search button
               public void actionPerformed(ActionEvent e) {
                    if (textFilter.getText().equals("")) {
                         JOptionPane.showMessageDialog(null, "No keyword has been entered");
                    } else {
                         int index = filterList.getSelectedIndex(); //get selected index
                         if (index == -1) { //no selection, so insert at beginning
                              index = 0;
                         } else { //add after the selected item
                              index++;
                         filterListModel.insertElementAt(textFilter.getText(), index);
                         //Reset the text field.
                         textFilter.requestFocusInWindow();
                         textFilter.setText("");
                         //Select the new item and make it visible.
                         filterList.setSelectedIndex(index);
                         filterList.ensureIndexIsVisible(index);
               }i also wanted to be able to detect selected items and display them as cyan in color. i have created 2 inner classes for this.
class MyListSelectionListener implements ListSelectionListener {
     public void valueChanged(ListSelectionEvent e) {
          if (e.getValueIsAdjusting() == false) {
               if (filterList.getSelectedIndex() == -1) {
                    //No selection, disable fire button.
                    removeFilter.setEnabled(false);
               } else {
                    //Selection, enable the fire button.
                    removeFilter.setEnabled(true);
} //end class MyListSelectionListener
class CustomCellRenderer extends JLabel implements ListCellRenderer {
     public Component getListCellRendererComponent(JList list, // the list being redrawn
     Object value, // value to display
     int index, // cell index
     boolean isSelected, // is the cell selected
     boolean cellHasFocus) // the list and the cell have
     //  the focus
     { //begin getListCellRendererComponent() body
          if (isSelected) { //set the background for selected
               setBackground(Color.cyan);
          } else { //set the background for not selected
               setBackground(Color.white);
          } //end else
          return this; //return component used to render
     } //end getListCellRendererComponent()
} //end class CustomCellRenderer any help is much appreciated

when i enter some text and click search, the text should appear in the JListThe section in the Swing tutorial on "How to Use Lists" has an example almost exactly like this:
http://java.sun.com/docs/books/tutorial/uiswing/components/list.html
i also wanted to be able to detect selected items and display them as cyan in color.It is generally better to extend the DefaultListCellRenderer (it extends JLabel) as some methods have been optimized for painting efficiency.
I don't know if this is your problem, but whenever you extend JLabel directly you need to use
setOpaque( true );
otherwise the background color is inherited from the parent component.

Similar Messages

  • Cannot place order ERROR: "There was a problem adding your product to cart"

    Hey guys,
    Well, once again Best Buy's online system is preventing me from making an order. It seems like nearly every time I log in I experience some new problem. This time, I'm unable to add anything to my cart. It doesn't matter what item I try to add to my cart or what browser I use or if I clear cookies...it happens every time, on every browser, with every product in the store. The error shows a red & white triangle with a message "There was a problem adding your product to cart".
    Just to clarify ahead of time: 1) I have already tried signing in using 4 different browsers (explorer, firefox, chrome, opera) & they all give the same error; 2) Prior to posting here I researched this problem & found out it is somewhat common & has been occurring since at least 2012 on BestBuy.com; 3) Every time someone posts in here about this problem, customer service offers the same "fix" every time - to sign out, clear their browser cache of cookies, shut down the browser, restart the browser, sign back in, etc.... The only problem is, this "solution" has not worked ONE time our of the many times this problem has cropped up in here over the past 3+ years. Why this "solution" keeps getting told to people even though it never works is beyond me. But, there you have it.
    Just to clarify: I have already tried this solution, And just like with everyone else before me, it didn't work for me either. So, what's the next step? There must be something else that can be done other than waiting a couple more days for it to magically fix itself (it seems that is the only thing that ever "works"...is to let several days go by and the problem ends up getting fixed in some back-end server-side patch up). 
    What I'm hoping for from you is a solution that can fix this immediately. This problem has already prevented me from making a couple purchases for items that were temporarily on sale over the past couple days. So, those are lost sales for Best Buy. What I'm hoping to do now is pre-order the Elder Scrolls Online (PS4) in order to take advantage of the $10 pre-order reward. The game releases on Tuesday the 9th. So, in order to get this done in time I need to place the order sometime today (on the 8th).
    With all these repeated technical problems making purchasing a chore & wasting my time every single time I want to buy a product it's almost as if Best Buy is telling customers "We don't care if our online system works reliably...go spend your money at Amazon instead". lol
    Thank you in advance for your timely help on this matter.
    -Marc (removed per forum guidelines)

    Hello mjswooosh,
    I'm very disheartened to hear that you've had ongoing problems when attempting to order from BestBuy.com. Our goal is ever to provide a fun and efficient shopping environment! Certainly creating aggravation serves neither you nor us and I apologize sincerely for this having been your experience.
    We recommend the troubleshooting steps you mentioned (i.e., clearing the browser cache, deleting temporary internet files and cookies) because this is the most common cause of this type of problem. I too have encountered this issue from time to time and these steps have almost always resolved the problem. I say almost always because there's one further step you can try: ensure that you have signed out of BestBuy.com, then perform the browser maintenance steps we've recommended. Afterward, before signing in to BestBuy.com, add your desired items to your cart and sign in as part of the checkout process. When the standard steps have not netted a resolution for me, this has solved the problem each time.
    I hope this helps. I'm very grateful that you took the time to write to us with your concerns and for sharing your very valuable feedback about your online experience.
    Sincerely,
    John|Social Media Specialist | Best Buy® Corporate
     Private Message

  • Problem adding HP J6400 all-in-one printer

    We have an HP Officejet J6400 all-in-one printer here at work, and all of our computers have had no problem adding this printer except one: an older iMac, PowerMac 6.1 (with the white domed base). The driver is installed, and the computer sees the driver, but when I click to add it eventually it gives me this error:
    "An error occurred while trying to add the selected printer. client-error-not-authorized"
    I was on the phone with HP for an hour and they couldn't figure it out on their end. Has anyone had a similar problem, or have a solution?

    Hi,
    I request you to try the following:
    For network connection:
    http://h10025.www1.hp.com/ewfrf/wc/document?docname=c03086294&tmp_task=useCategory&cc=us&dlc=en&lc=e...
     For USB:
    http://h10025.www1.hp.com/ewfrf/wc/document?docname=c03521864&tmp_task=useCategory&cc=us&dlc=en&lc=e...
    Although I am an HP employee, I am speaking for myself and not for HP.
    Say thanks by clicking the "
    Kudos! Thumps Up" which is on the right
    Make it easier for other people to find solutions, by marking my answer with "Accept as Solution" if it solves your issue
    Regards,
    Ray

  • I upgraded to Mountain from Snow and find that there is now a problem adding iphoto to the cloud.  I have iphoto '08,version 7.1.5.  Tried to follow one poster's advice and upgrade to 9.1 but I need 9.0 first and I can't find that.  suggestions? thanks!

    I upgraded to Mountain from Snow and find that there is now a problem adding iphoto to the cloud.  I have iphoto '08,version 7.1.5.  Tried to follow one poster's advice and upgrade to 9.1 but I need 9.0 first and I can't find that.  suggestions? thanks!

    You have to buy iPhoto from the Mac App Store.

  • Issue / problem adding audio in Presenter 7 (PowerPoint 2010)

    Since I got a new PC (Windows 7), I'm having an issue / problem adding audio in Presenter 7 (PowerPoint 2010).
    It doesn’t happen every time, but randomly with many presentations...
    In PowerPoint, right after I import audio (through Presenter) and click “ok”, I get the following errors:
    Then, I can't get into the "import/sync/edit" mode, from the Presenter tab...
    Already tried reinstalling Presenter, resaving new presentations, deleting the .ppcx/audio folders, importing the audio locally (vs from my network drive), etc.
    Then sometimes, randomly, it will let me get back in and edit the audio, after numerous attempts…?!? I can't figure out what the pattern is, which is causing this new problem (never had this problem before, w/ my old PC - Win XP / PowerPoint 2003 / Presenter 6 & 7)
    Anybody have an idea what the issue could be?
    Thanks,
    Mike P.

    Hello,
    I  tried to reproduce this issue but I am not getting any error message. Please provide us following information; this might help to reproduce this issue:-
    1) You are seeing this issue in  PPT or PPTX
    2) You seeing this issue in newly created presentations or its just old presentation which is not working properly.
    3) OS and PowerPoint version
    4) If this issue is consistent on any particular presentation then please share it.
    5) Can we have exact reproducible steps
    Regards,
    Shubhi

  • All new podcasts blank - There was a problem adding "" to iTunes.

    All new podcast episodes have a blank name, but the description is there. Clicking the exclamation point next to it yields - There was a problem adding "" to itunes.
    This is not just my old subscriptions but new ones as well. The episode actually downloads completely but does not get added to my library.
    Anybody have a suggestion how to resolve this?

    After days of no solution, as soon as I post it decides to resolve this by itself.

  • Problem adding elements to a group after removing everything...

    Hi everyone,
    I would really appreciate some help on something. I have a Group that has some Buttons in it. This Group is in one of fours States, and there is a componant for each State. After the user goes through the rest of the program and comes back to this State, I want to remove the old buttons, and add new buttons with new values. Bascially, I want to refresh the componant when it is visited a second time. I have a problem adding new Buttons to the group when the user revisits the componant / state.
    The group is created:
              <s:VGroup id="buttons"  x="0" y="35"  height="400" width="280" />
    When the init function for that componant is called, buttons are added from an array of buttons:
    for(var i:int = 0; i < 10; i++){
              var button:Button = questions[i];
              trace(button);
              button.addEventListener(MouseEvent.CLICK, myEventHandler);
              trace(buttons);
              buttons.addElement(button);
    When the user moves on to the next State, the buttons are removed:
    if(counter == 4){
              buttons.removeAllElements();
              FlexGlobals.topLevelApplication.currentState = 'Summary';
    When the user comes back to the initial state, the buttons are not added to the Group like they are the first time. The output of the trace as each button is added is also different the second time:
    First time: (successful)
    Main.MainBackground2.contentGroup.gameComp.buttons
    button8
    Second time:
    buttons
    button8
    Can anyone point me in the right direction? And better question, is there a better way I should be doing this?
    Is there a better way to refresh everything within a component upon viewing it s second time?
    Thanks in advance!

    I'm not sure why you are using addElement() to add the buttons. Aren't you supposed to let the state functionality handle when the buttons should be visible? That's the cleanest way to do it in most cases. You may want to post a larger code sample, where you have boiled down the code into a minimal sample that still enhibits the issue.
    If this post answers your question or helps, please mark it as such.
    Greg Lafrance - Flex 2 and 3 ACE certified
    www.ChikaraDev.com
    Flex Training and Support Services

  • Problem adding Video to Captivate Slide

    Hi,
    I'm having a problem adding an FLV video file to Captivate. Basically, after I've published to a SWF file, the video doesn't appear on the slide at all. It's just blank.
    After researching a bit, I found that the FLV file MUST include *metadata*.
    However, I added medatada with VLC Media Player, and it still shows the same behavior. Must it include a certain *amount* of metadata? Is there a *type* of metadata without which the video will not show?
    Adobe's Help thread talks about something called the "Flash Video Kit" - is that a stand alone product or an extension of another product? Is it free? Are there any other free alternatives?
    I'm just very confused.
    Thank you!

    I ended up answering my own question. But just in case this helps anyone else, I'm going to post my solution.
    Essentially, I just re-created the video in MP4 format. Then I used MetaZ (for Mac) to write Meta Data to the video. Lastly, I imported the video as an object and when I published the video, Captivate transmuted it to the necessary FLV format.
    Now the video displays properly.

  • Problem adding interaction in CS 5.5 trial

    Hi,
    I have installed (twice) the Flash Catalyst 5.5 trial and still can not resolve this problem: after selecting a component (and with at least two states/pages) the
    "Add Interaction" button in the INTERACTIONS panel does not populate any options in the CHOOSE STATE drop down menu. I can't point to any states.
    Is this a bug (in the TRIAL) or am I missing something that needs to happen first?
    Viro
    PS: I'd be surprised if this basic work flow has changed (it's so straight forward in CS 5) , and I haven't seen anything in the current documentation, either in the help or on adobe TV tutorials that contradict this procedure.

    Thanks to another poster and the answer below I have figured out that the problem was in fact of my own making. Another case of RTFM!
    I still don't understand why this implementation was made, although I'm sure it extends the functionality of this application. Anybody?
    5. May 27, 2011 12:08 PM
    Re: Problems adding Interaction to button
    In Flash Catalyst 5.5, you need to change the Choose Target menu to Application, then the next drop down list will populate with the State names, select the state that you want, and click OK. You can control when this happens further by using the When in Any State menu. That menu will allow you automatically restrict which state it works in.
    Hope this helps
    Chris

  • Problems adding Bridge Data to prepaid (Allset) iPhone5

    Anyone having problems trying to add bridge data to a prepaid (Allset) phone. I've tried to add 3GB to my iPhone 5 all day today and I've had no success. I've tried doing through (1) the new My Verizon Mobile App, (2) dialing *611 and following the prompts and (3) on my PC while logged into my "My Verizon" account. All three methods result in a "system error" and I can't add any bridge data. The only thing that worked, was it allowed me to put $25 on account by charging my credit card. So now I've been taken for $25 and can't do anything with the money on now have in my account. A call to customer service was a complete waste of time. The CSR told me to do the *228 Activation code on my 4G LTE iPhone 5. I'm not a CSR and I know you don't use *228 on an a 4G iPhone! After wasting 30 minutes and being told my SIM card "had to age" (very creative), I got tired of the snow job and hung up. Is anyone else having problems adding bridge data? Please advise if you have succeeded in adding bridge data today.

    Why have a Prepaid forum that is not monitored by CSR's who can actually do something about the issues posted by Prepaid customers? I'm not looking for a "sorry to hear about your problem" reply, I'm looking for answers/solutions. 
    What a ridiculous arrangement. This Prepaid sub-forum should be deleted so customers don't waste their time posting problems here.
    Sent from my iPad

  • Problems adding an image title?

    Hi,
    When I place an image in Muse I'm having problems adding an image title. When I Control click the image in Design view the choices I get at the bottom of the pop up menu are
    Edit original
    Edit Image Properties
    When I looked it up in help it tells me I should also see another item "Add Title" but I don't get that as a choice. When I click on "Edit Image Properties" I get a choice of Tooltips or Alt Text but no place for a title.
    Thanks,
    Bill

    This is the page
    http://www.adobekb.com/strategies_for_seo.html#addingmetadata
    To be clear when I right click on an image I only get the choice of "Edit Original" & "Edit Image Properties". When I click on "Edit Image Properties" I only get a choice of Tooltips or Alt Text, nothing for title
    Thanks,
    Bill
    Adding titles and alternative text to images
    After you place images on a page, you can access the Image Properties dialog box to set both a title and alternative text (also sometimes called alt text) that is assigned to the image.
    Here's a brief description of each property:
    Title: In many browsers, the title is displayed in addition to the image, typically as a tooltip that appears when a cursor hovers over it.
    Alternate text: If the image file cannot be shown, this text is displayed in place of the image. Alternate text is also used to describe images to visually impaired visitors using assistive technologies to access page content.
    It is ideal to set titles and alternative text for every site asset, to ensure that visitors have the best experience when navigating your site. Tooltips are helpful for including additional information about graphics and alternative text makes pages more accessible for screen readers that verbally present graphic content.
    To add titles and alternative text, follow these steps:
    1. Select a placed image.
    2. Right-click on the image and select Add Title or Add Alternative Text from the context menu that appears (see Figure 3).

  • Having problems adding packages

    I downloaded the Solaris (Sparc) companion CD's Dependency Package. It contains 14 or so files that I think should be patches. I run "pkgadd -d . " from my directory where they are and it says their are no packages to add.
    http://www.sun.com/software/solaris/freeware/pkgs_download.html#bundle
    Is where I got the package from.
    I have re-downloaded it like 5 times. I am running Solaris 9 on a Ultra 5. I have not had any problems adding packages before. The packages that I am trying to add are in thier own slice and I have a lot of room on my disks.

    I think I am having an ID10T error.
    I didn't realize the paths that I was giving it were incorrect.

  • Problem adding recordset to a Template page

    I've been having problems adding sql recordset to a Template page, when i set the record the editable region of the template is no longer editable and it begins to be editable everything else, one more thing that happens with the record is that is partially inserted into the body of the php page, i have tried to reinstall wampserver, dreamweaver, delete the folder with the user settings and the registry of dreamweaver but nothing seems to work, the only thing that i haven't tried is delete the folder with the main settings, but i don't think that it is the problem
    sorry for the bad english.
    Any help would be greatly appreciated.

    Your library is damaged and my not be able to be totally recovered, i.e. recover albums, slideshows, etc. along with the photos.
    If the original files for your photos are inside the library package (even if iPhoto can't display them) the following should create a new library with all of your photos. 
    Start over from scratch with new library
    Start over with a new library and import the Originals (iPhoto 09 and earlier) or the Masters (iPhoto 11) folder from your original library as follows:
    1.  Move the existing library folder to the desktop.
    2. Open the library package like this.
    Click to view full size
    3. Launch iPhoto and, when asked, select the option to create a new library.
    4. Drag the Originals (iPhoto 09 and earlier) or the Masters (iPhoto 11) folder from the iPhoto Library on the desktop into the open iPhoto window.
    Click to view full size
    This will create a new library with the same Events as the original library but will not keep the metadata, albums, books slideshows and other projects.  Check it out carefully to see if all of your photos are represented in it.
    Your current library will still be available for further fix attempts.

  • Problems adding virtual channels in Max

    Has anybody had any problems adding new virtual channels to an existing DAQ OPC configuration? We have a working configuration using 99 tags and adding a further tag to bring the total to 100 causes an OPC server failure. Any help or clues would be appreciated.

    Hi mak90,
    There are no ways to change the sensor range and physical ranges
    programmatically in Traditional DAQ. Under DAQmx, you have Scaling VIs,
    Calibration VIs, Task VIs that allow you to change various settings in
    MAX programmatically.
    Please let us know if you have any further questions.
    Best regards,
    Nathan Yang
    Applications Engineer
    National Instruments

  • Problems adding Text track to .mov file

    I am having a problem adding a text track to a quicktime file. I want to overlay text onto a PAL DV file. The original file size is 720 x 576 but when I add the text (as per the instructions in the QT Player Help) instead of having the text overlaid, it appears next to the Video image and gives me an image size of 1325 x 577. If I now export this as a "PAL DV" file, QT Player shows the whole 1325x577 frame whilst FCP accepts the file but shows only the video part of the frame.
    I'm running QT 7.4.5 on a MacBook Pro with OS10.5.2. I have tried re-installing QT without success - this maybe because the Preferences seem to stick when upgrading/re-installing (?)
    Any thoughts, help or, better still, a definitive answer to my problem would be most welcome.

    Use the Movie Properties window to size your added text track to match the 720 width.
    For viewing a DVD on a TV size it even smaller (700) and set an offset value of 10 pixels so your text doesn't get cut off during playback.

Maybe you are looking for

  • New DVR, Can't Recognize Existing ESata Drive/Prog​rams

    I had a Motorola 7216 DVR box that had an external ESata drive.  The box had three issues:  froze 2-3 times a day for maybe 30 seconds, sound "clipping" during loud sections of shows/movies, and I could never get the Android app or web app to connect

  • Add a field to a cube in BI 7.0

    Hi, I want to add a charachteristic to an infocude without deleting the data in the infocube. I guess that REMODELING is the solution, but I'm not sure wich alternative to choose. Or even if REMODELING is the right solution? The field I want to add t

  • Trying to email file from adobe reader 11.0 email addresses will not longer auto complete after moving to office 365

    trying to email file from adobe reader 11.0 email addresses will not longer auto complete after moving to office 365. It did work with older versions of outlook. Tried changing to global address book. It will only access global address book offline

  • To change the layout of the front end

    I am working in c projects it is a web enabled server at the front end and at the back end it is sap I have to make changes in front end to add two i/p fields and backend it should update the sap table Please help Regards Abhijit Chitre

  • Problem with download link in Oracle 9i Lite page?

    Hello, I get a cannot find server/The page cannot be displayed error when attempting to download 9i Lite for Windows. http://download.oracle.com/otn/nt/oraclelite/olite502_win.zip Is this a known issue? Can anyone else get to it? Thanks. Julian