ListCellRenderer and JList... cannot set the selected background?

The following code:
     public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus )
          setText( "test" );
          setBackground( isSelected ? list.getSelectionBackground() : list.getBackground() );
          setForeground( isSelected ? list.getSelectionForeground() : list.getForeground() );
          return this;
     }is having problems. It does not set the background color for the selected item. It does, however set the foreground. If I don't use my own cell renderer, the background changes as expected. I can't figure out why - I can set the border of the JLabel that is returned, the foreground, the icon, but not the background.
What am I doing wrong?

I would have to check, but from memory a cell is a JLabel not a JTextField. The diff is that a JLabel is transparent so the background colour is normaly that of the JPanel. In a JTable I presume the cell has some default background colour based on the table, so maybe you need to use a JTextField to define the field.
Hope that helps,
James.

Similar Messages

  • How do you set the selected item of a combobox?

    I looked around and didn't find an intrinsic method or
    function to set the selected index of a combobox. I wrote a
    function, but I thought I would see what the "best" way of doing it
    is?
    The function I wrote is;
    private function
    setComboSelectedItem(cmbBoxIn:ComboBox,strFindItem:String):void
    for (var i:int=0;i<cmbBoxIn.dataProvider.length;i++)
    if (cmbBoxIn.dataProvider(I) == strFindItem)
    cmbBoxIn.selectedIndex = i;
    break;
    The parentheses surrounding "i" above should be square
    brackets, but they do not display.
    Paul

    doing a calllater will solve this problem if your changing
    dataprovider and trying to set the selected index on an editable
    combox

  • My ipod nano will turn on and play but the viewing screen goes out and I cannot access the information to select different playing options. Any suggestions?

    My ipod nano will turn on and play but the viewing screen will not come on and I cannot access the information to select different playing options. It glows white background light then goes dark for the entire time I am using it. Any suggestions?

    I had the same problem.  Someone here told me to make sure my earbuds were in securely.  Push until they click in place.  It solved the problem.  The music still plays even though the screen goes to sleep.  Hope this helps.

  • Setting up my new Airport Extreme and it cannot find the IP address?  The modem works fine when I bypass the Airport.

    Setting up my new Airport Extremem and it cannot find the IP address.

    Re: Airport Extreme IP Address Issue
    After hours of trying everything else, this worked!!!
    From: Comcast Networking/Router/Wifi Gateway:
    Re: Airport Extreme IP Address Issue
    11-20-2012 07:11 PM
    MyComputerGuyJo:
    I just wanted to add what Apple Support walked me through. Worked perfectly. Similar to some of the posts here. This assumes you have finished the setup of the Airport using DHCP to obtain the IP automatically from Comcast and it says the IP is invalid.
    Power off\on Sequence
    1, Power off Comcast Modem. Remove Battery back up, if it has one. Disconnect the coax cable.
    2. Power off Airport Extreme
    3. Let both sit for 3 minutes.
    4. Reconnect coax cable to Comcast modem and replace battery and power up.
    5. Wait a minute or two to make sure the Comcast modem is completely up and then Power on the Airport Extreme.
    (When AP asks for DNS, Type in both addresses below)
    Re: Airport Extreme IP Address Issue
    11-01-2012 03:07 PM
    Freyfisher: I had the same problem whenn I switched to the Airport Extreme yesterday.  Here is what I did:
    1:  uplugged modem for 30 sec. and detached all ethernet cables.  Plugged back in and reattached airport extreme cable after all lights were solid on the modem. Then, I went into Airport Utility and selected, "Base Station"> "restore default settings".  Then" Base Station"> Restart.  Then go through setup assistant again.  If no luck, try setting IPv4 to 10.0.1.2, subnet to 255.255.255.0, router to 10.0.1.1. IPv6 set to OFF if having trouble.  DNS adresses: 75.75.75.75, 75.75.76.76, search domain hsd1.ST.comcast.net where "ST" is your two-letter State abbrev.  Hope this helps someone....

  • I bought an apple iPod 5th generation the other day and I cannot remember the unlock passcode. I have done the restore thing, but because I never set it up or synced it with iTunes, it does not recognize my device. It is disabled for one hour. Please help

    I bought an apple iPod 5th generation the other day and I cannot remember the unlock passcode. I have done the restore thing, but because I never set it up or synced it with iTunes, it does not recognize my device. It is disabled for one hour. There's only a few things that could be my passcode, but because it disables for an hour, it is time consuming trying to figure it out. What do I do? I do not care about having to erase everything since it's new and there's nothing on it, but it was never synced with iTunes.

    Disabled
    Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
    iOS: Wrong passcode results in red disabled screen                         
    If recovery mode does not work try DFU mode.                        
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings        
    For how to restore:
    iTunes: Restoring iOS software
    To restore from backup see:
    iOS: Back up and restore your iOS device with iCloud or iTunes
    If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
    You can redownload most iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store        
    If problem what happens or does not happen and when in the instructions? When you successfully get the iPod in recovery mode and connect to computer iTunes should say it found an iPod in recovery mode.

  • All of my apple sets (iphone, ipad and computer) cannot connect the app store since yesterday, what's wrong with the app store?

    All of my apple sets (iphone, ipad and computer) cannot connect the app store since yesterday, what's wrong with the app store? do you know? or do you have have the same experience?

    I still have access.  Must be your phone or your internet connection.

  • How to set the Selected row and Column in JTable

    Hi,
    i have a problem like the JTable having one Method getSelectedRow() and getSelectedColumn to know the Selected row and Column but if i want to explicitly set the Selected Row and Column,then there is no such type of Methods.If anybody has any solution then i will be thankful to him/her.
    Praveen K Saxena

    Is that what you're looking for? :myTable.getSelectionModel().setSelectionInterval(row, row);
    myTable.getColumnModel().getSelectionModel().setSelectionInterval(column, column);

  • Hello, I just bought a 2013 Mac mini and I cannot get the sound to output to my Dell U2713HM monitor.  I went to sound output but even though my Dell shows up there when I select it there is no sound output to it.  I am using a mini DP to DP cable...

    Hello, I just bought a 2013 Mac mini and I cannot get the sound to output to my Dell U2713HM monitor.  I went to sound output but even though my Dell shows up there when I select it there is no sound output to it.  I am using a mini DP to DP cable...Any ideas? Thanks

    Hi Alxx911, and John Hammer1. After reading John's reply - " You can plug something into it's headphone jack. though" . I thought i'd try out of curiosity. I plugged in some headphones. I didn't expect anything to happen  and nothing happened. The audio jack is for the Dell soundbar which is optional.
    Here's a direct copy and paste from the users manual: Section About Your Monitor.
    Attaching the Soundbar AX510 / AX510PA (Optional) CAUTION: Do not use with any device other than the Dell Soundbar. NOTE: The Soundbar power connector (+12 V DC output) is for the optional Dell Soundbar AX510/AX510PAonly. To attach the Soundbar: 1. Working from the back of the monitor, attach the Soundbar by aligning the two slots with the two tabs along the bottom of the monitor. 2. Slide the Soundbar to the left until it snaps into place. 3.  Connectthe Soundbar with the DC power connector. 4. Insert the mini stereo plug from the back of the Soundbar into the computerís audio output jack. For HDMI/DP, you can insert the mini stereo plug into the monitorís audio output port.  If there is no sound, check your PC if the Audio output is configured to HDMI/DP output.
    This monitor has no speakers. (Like John Hammer1 mentioned). The no speakers feature was one of the reasons I chose this monitor.
    Good Luck !

  • How do you have Google searches appear in new tab? This was previously not a problem, but it changed and I cannot return the setting. Any ideas?

    How do you have Google searches appear in new tab? This was previously not a problem, but it changed and I cannot return the setting. Any ideas?

    I recently purchased a second hand new macbook air, although it was second hand to me the previous owner had never actually turned it on.
    Something doesn't make sense here, though I'm not saying the previous owner is lying....
    Time to send your serial # to iTS and let them see what's happening here.
    iTunes Store Support
    http://www.apple.com/emea/support/itunes/contact.html

  • HT5085 my divece is dead and i cannot set up the icloud

    my divece is dead and i cannot set up the

    Is the battery on your device empty ? It can take up to 15 minutes of charging before a device will respond. And have you tried a soft-reset on it to see if that gets it to boot up ? Press and hold both the sleep and home buttons for about 10 to 15 seconds, after which the Apple logo should appear - you won't lose any content, it's the equivalent of a reboot.
    If you can't get the device to power on then you won't be able to enable icloud on it.

  • I have an IPhone operating OS 4.21. I cannot back it up before update and I cannot set up an ICloud account as it needs to be on a version later on the device. Please help, I want to update but not lose everything!

    I have an IPhone operating OS 4.21. I cannot back it up before update and I cannot set up an ICloud account as it needs to be on a version later on the device. Please help, I want to update but not lose everything!

    SorchaH wrote:
    I receive an error "Itunes cannot back up the IPhone because the back up cannot be saved on the computer".. So I tried to download and log into ICLoud but need to do this from my device..
    That would tend to indicate a permissions issues on the computer.
    Running an outdated version of iTunes is of absolutely no benefit.
    All iDevices work with the current version of iTunes.

  • Cannot set the initial size of nested JFrame in NetBeans 5.5.

    For some background; I'm trying to design a small configurable, multi-market clock for Traders of foreign currency. Several international market times will be displayed and each will change color as that market opens and closes. The user will be able to select specific foreign markets and configure several options such as color and size.
    I was trying to use a JFrame for the initial window and an undecorated JFrame to hold the clocks and their labels. In the GUI builder for the initial JFrame, I dragged a JFrame and dropped it outside the original to add an (other Component). My problem is that I can't set the prefereedSize or the minimumSize properties for the nested JFrame. When I run the program, a button sets the second JFrame visible but at (0,0) size which when undecorated is invisible, and when decorated shows only the Min/Max/Close buttons. Am I just going about this all wrong or is this a bug
    I am running Java Version 1.5.0 (build 1.5.0_08-b03)
    Rick

    I have tried to use several different components but I have not been able to get them to appear as a component, undocked from the main window.
    Another idea that I tried was to have the whole program run from the same frame and then just set the window as undecorated and hide the menu bar. Unfortunately decorated state cannot be changed after it is displayable or packed. Besides that, how do you then make it moveable when there is no title bar? So many questions? Any other suggestions?

  • Unable to set the selected value for a ADF LOV

    Hi,
    I am developing an application using jdeveloper 10.1.3 and Struts.
    I have created a ADF LOV on my JSP Page as given below:
    <html:select property="lob" onchange="javascript:selectLOB(this.form)">
    <html:optionsCollection label="prompt" value="index" property="lob.displayData"/>
    </html:select>
    When i submit the form, i am able to get the value of the selected Value in the List.
    JUCtrlListBinding listBinding = (JUCtrlListBinding) formBean.get("Lob");
    Row r = (Row) listBinding.getSelectedValue();
    String SoLob = (String) r.getAttribute("LobLob");
    But i am unable to set the selected value back in the list when i return to the form again.
    I tried the following:
    int x = listBinding.getSelectedIndex();
    listBinding.setSelectedIndex(x);
    It would be really helpful if some one could let me know what needs to be done.
    Thanks,
    Subashini

    Gyan,
    I tried with the code you suggest , its trying to set the value of a field, but my requirement is to change the property for
    "Rendered" on the field so that based on search parameters we can hide result table column.
    After searching online, I modified the controller code as follows
    1.Created a new transient attribute (Testrender) with type "Boolean" and always updateable.
    2.changed the "Rendered" property value on the field I want to hide as ${oa.PoSearchVO1.Testrender}.
    3. Modified the controller code as follows :
            OAApplicationModule am = pageContext.getApplicationModule(webBean);
            OAViewObject testvo = (OAViewObject)am.findViewObject("PoSearchVO1");
            OADBTransaction txn = am.getOADBTransaction();
            if (testvo != null)
              OARow row = (OARow)testvo.first();
                if (a.equalsIgnoreCase("Approved"))
                     row.setAttribute("Testrender", Boolean.FALSE);
                else
                     row.setAttribute("Testrender", Boolean.TRUE);
            } But now when i run the page and populate the search field and click "Go" its hiding the field but throwing the following error and the search results are also bad.
    Its using only the value of one search parameter but not the second one .
    The search cannot be executed because the table has pending changes that would be lost. I think the vo is getting dirty when I update the transient attribute value. So I used txn.rollback ,then search is working fine but its not hiding the field.
    So can you please let me know how to proceed from here ?

  • Hi. After I have loaded a picture into Photoshop some of the menu tools are greyed out and I cannot use the keyboard short cut, for instance I cannot use Ctrl   T to enter free transform mode. Also the toolbar is so small I cannot see the icons without ge

    Hi. After loading a picture into Photoshop some of the menu tools are greyed out and I cannot use the keyboard short cuts, for instance I cannot use Ctrl + T for free transform, how do I resolve this problem. In addition the tool Icons are so small I have to get close to the screen to see them, is there anyway the Icons can be made bigger without reducing the resolution of the screen.
    Thanks
    Derek

    Are you working on a background layer? If so, Ctrl + T will not work. Press Alt and double-click your background layer to convert to a normal layer (or right-click BG layer and select Layer from Background) and try again.
    If you're working in Photoshop CC 2014 you can go to Preferences > Experimental Features and tick "Scale UI 200% for high-density displays" to make your buttons and icons larger.

  • Cannot save the selected regions

    I'm just trying to set up a site for a client. I don't use Dreamweaver so I'm trying to create editable regions in the browser, following the instructions (http://help.adobe.com/en_US/InContextEditing/Administrator/index.html#editable).
    When I put a tick in the checkbox and click on Save, I get an error message: "You cannot save the selected regions, etc". The region is not dynamically generated - in fact this is a very simple static page with no scripts at all, nothing complicated. Here's the URL: http://www.artonhart.com.au/guestbook.html
    The region I'm trying to select is a td, id=guestbook.
    What to do?
    Jen

    Well... as for the table structure thats not exactly correct. The proper way to code a table is as follows
    Please read this thread: Re:  Editing a Table using ICE
    define div
         define table
              define table body (create a repeating group if you have repeating cells)
              define table rows
                   define table headings (can be editable if enabled)
                   define table rows (enable repeating if you like)
                        define table data (create editable cells)
    <div
    id="repeating-table">
      <table width="100%" id="Name_Table">
    <tbody ice:repeatinggroup="*">
          <tr>
           <th width="331"> <h2>Column Heading 1 </h2></th>
    <th width="76"> <h2>Column Heading 2 </h2></th>
    <th width="58"> <h2>Column Heading 3 </h2></th>
    <th width="50"> <h2>Column Heading 4 </h2></th>
    <th width="50"> <h2>Column Heading 5 </h2></th>
    <th width="42"> <h2>Column Heading 6 </h2></th>
    <th width="55"> <h2>Column Heading 7 </h2></th>
    </tr>
          <tr ice:repeating="true">
            <td
    class="style-it" ice:editable="*">content 1</td>
    <td ice:editable="*">content 2</td>
            <td
    ice:editable="*">content 3</td>
            <td
    ice:editable="*">content 4</td>
            <td
    ice:editable="*">content 5</td>
            <td
    ice:editable="*">content 6</td>
            <td
    ice:editable="*">content 7</td>
          </tr>
    </tbody>
      </table>
    </div>

Maybe you are looking for